mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-08 00:52:55 +00:00
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
// RING RACERS
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 2023 by James Robert Roman
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef __SRB2_MEDIA_YUV420P_HPP__
|
|
#define __SRB2_MEDIA_YUV420P_HPP__
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#include "video_frame.hpp"
|
|
|
|
namespace srb2::media
|
|
{
|
|
|
|
class YUV420pFrame : public VideoFrame
|
|
{
|
|
public:
|
|
// 32-byte aligned for AVX optimizations (see libyuv)
|
|
static constexpr int kAlignment = 32;
|
|
|
|
class BufferRGBA : public VideoFrame::Buffer
|
|
{
|
|
public:
|
|
bool resize(int width, int height); // true if resized
|
|
|
|
void erase(); // fills with black
|
|
void release();
|
|
|
|
int width() const { return width_; }
|
|
int height() const { return height_; }
|
|
|
|
private:
|
|
int width_, height_;
|
|
|
|
std::vector<uint8_t> vec_;
|
|
};
|
|
|
|
YUV420pFrame(int pts, Buffer y, Buffer u, Buffer v, const BufferRGBA& rgba);
|
|
|
|
virtual ~YUV420pFrame();
|
|
|
|
// Simply resets PTS and RGBA buffer while keeping YUV
|
|
// buffers intact.
|
|
void reset(int pts, const BufferRGBA& rgba) { *this = YUV420pFrame(pts, y_, u_, v_, rgba); }
|
|
|
|
// Converts RGBA buffer to YUV planes.
|
|
void convert() const;
|
|
|
|
// Scales the existing buffer into a new one. This new
|
|
// buffer replaces the existing one.
|
|
void scale(const BufferRGBA& rgba);
|
|
|
|
virtual int width() const override { return rgba_->width(); }
|
|
virtual int height() const override { return rgba_->height(); }
|
|
|
|
virtual const Buffer& rgba_buffer() const override;
|
|
|
|
private:
|
|
Buffer y_, u_, v_;
|
|
const BufferRGBA* rgba_;
|
|
};
|
|
|
|
}; // namespace srb2::media
|
|
|
|
#endif // __SRB2_MEDIA_YUV420P_HPP__
|