Go to the documentation of this file.
8 #include "libavcodec/avcodec.h"
11 #define LOC QString("VideoFrame: ")
25 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Frame still contains a hardware buffer!");
36 int Width,
int Height,
const VideoFrameTypes* RenderFormats,
int Alignment)
45 uint8_t* newbuffer =
nullptr;
57 int Width,
int Height,
const VideoFrameTypes* RenderFormats,
int Alignment)
61 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Trying to reinitialise a hardware frame. Ignoring");
65 if (std::any_of(
m_priv.cbegin(),
m_priv.cend(), [](
const uint8_t* P) { return P != nullptr; }))
67 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Priv buffers are set (hardware frame?). Ignoring Init");
73 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Inconsistent frame buffer data");
79 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"Deleting old frame buffer");
96 int alignedwidth = Alignment > 0 ? (
m_width + Alignment - 1) & ~(Alignment - 1) :
m_width;
99 for (
uint i = 0; i < 3; ++i)
105 m_offsets[1] = alignedwidth * alignedheight;
110 m_offsets[1] = (alignedwidth << 1) * alignedheight;
115 m_offsets[1] = alignedwidth * alignedheight;
120 m_offsets[1] = (alignedwidth << 1) * alignedheight;
125 m_offsets[1] = alignedwidth * alignedheight;
130 m_offsets[1] = (alignedwidth << 1) * alignedheight;
135 m_offsets[1] = alignedwidth * alignedheight;
140 m_offsets[1] = (alignedwidth << 1) * alignedheight;
188 int PlaneWidth,
int PlaneHeight)
190 if ((ToPitch == PlaneWidth) && (FromPitch == PlaneWidth))
192 memcpy(To, From,
static_cast<size_t>(PlaneWidth * PlaneHeight));
196 for (
int y = 0; y < PlaneHeight; y++)
198 memcpy(To, From,
static_cast<size_t>(PlaneWidth));
211 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Cannot clear a hardware frame");
228 unsigned char uv1 = (uv & 0xff00) >> 8;
229 unsigned char uv2 = (uv & 0x00ff);
232 for (
int row = 0; row < uv_height; ++row)
234 for (
int col = 0; col <
m_pitches[1]; col += 2)
236 buf1[col] = buf2[col] = uv1;
237 buf1[col + 1] = buf2[col + 1] = uv2;
251 unsigned char uv1 = (uv & 0xff00) >> 8;
252 unsigned char uv2 = (uv & 0x00ff);
254 for (
int row = 0; row < uv_height; ++row)
256 for (
int col = 0; col <
m_pitches[1]; col += 4)
258 buf3[col] = buf3[col + 2] = uv1;
259 buf3[col + 1] = buf3[col + 3] = uv2;
277 if (!From || (
this == From))
282 LOG(VB_GENERAL, LOG_ERR,
"Cannot copy frames of differing types");
288 LOG(VB_GENERAL, LOG_ERR,
"Invalid frame format");
295 LOG(VB_GENERAL, LOG_ERR,
"Invalid frame sizes");
301 LOG(VB_GENERAL, LOG_ERR,
"Invalid frames for copying");
309 LOG(VB_GENERAL, LOG_ERR,
"Invalid buffer size");
318 for (
uint plane = 0; plane < count; plane++)
402 case FMT_VTB:
return "VideoToolBox";
419 int adj_w = Aligned ? ((Width + Aligned - 1) & ~(Aligned - 1)) : Width;
423 int remainder = (adj_w * adj_h * bpp) % bpb;
424 return static_cast<uint>((adj_w * adj_h * bpp) / bpb + (remainder ? 1 : 0));
429 return static_cast<uint8_t*
>(av_malloc(Size + 64));
462 QString result = DoubleRate ?
"2x " :
"";
515 case DEINT_HIGH:
return result +
"Compensated";
530 return QString(
"None");
MythDeintType GetDoubleRateOption(MythDeintType Type, MythDeintType Override=DEINT_NONE) const
static int GetPitchForPlane(VideoFrameType Type, int Width, uint Plane)
static MythDeintType ParseDeinterlacer(const QString &Deinterlacer)
static bool PackedFormat(VideoFrameType Type)
MythDeintType m_deinterlaceAllowed
void ClearBufferToBlank()
#define DEINT_QUALITY_LOW
#define DEINT_QUALITY_SHADER
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void Init(VideoFrameType Type, int Width, int Height, const VideoFrameTypes *RenderFormats=nullptr)
static bool HardwareFormat(VideoFrameType Type)
static bool FormatIs422(VideoFrameType Type)
#define MYTH_HEIGHT_ALIGNMENT
static int BitsPerPixel(VideoFrameType Type)
MythDeintType m_deinterlaceDouble
static size_t GetBufferSize(VideoFrameType Type, int Width, int Height, int Aligned=MYTH_WIDTH_ALIGNMENT)
#define DEINT_QUALITY_HIGH
static void CopyPlane(uint8_t *To, int ToPitch, const uint8_t *From, int FromPitch, int PlaneWidth, int PlaneHeight)
bool m_alreadyDeinterlaced
int64_t m_displayTimecode
std::vector< VideoFrameType > VideoFrameTypes
const std::array< const std::string, 8 > formats
#define DEINT_QUALITY_MEDIUM
static uint8_t * CreateBuffer(VideoFrameType Type, int Width, int Height)
static int ColorDepth(int Format)
static MythDeintType GetDeinterlacer(MythDeintType Option)
const VideoFrameTypes * m_renderFormats
static bool FormatIs444(VideoFrameType Type)
static QString DeinterlacerPref(MythDeintType Deint)
static bool FormatIs420(VideoFrameType Type)
MythDeintType GetSingleRateOption(MythDeintType Type, MythDeintType Override=DEINT_NONE) const
static int GetHeightForPlane(VideoFrameType Type, int Height, uint Plane)
static QString FormatDescription(VideoFrameType Type)
static const VideoFrameTypes kDefaultRenderFormats
static QString DeinterlacerName(MythDeintType Deint, bool DoubleRate, VideoFrameType Format=FMT_NONE)
static uint GetNumPlanes(VideoFrameType Type)
#define DEINT_QUALITY_DRIVER
@ FMT_RGB32
endian dependent format, ARGB or BGRA
static uint8_t * GetAlignedBuffer(size_t Size)
MythDeintType m_deinterlaceInuse
bool CopyFrame(MythVideoFrame *From)
static bool FormatIsNV12(VideoFrameType Type)
MythDeintType m_deinterlaceSingle
bool m_deinterlaceInuse2x
std::array< uint8_t *, 4 > m_priv