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!");
27 av_freep(
reinterpret_cast<void*
>(&
m_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");
80 av_freep(
reinterpret_cast<void*
>(&
m_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;
189 int PlaneWidth,
int PlaneHeight)
191 if ((ToPitch == PlaneWidth) && (FromPitch == PlaneWidth))
193 memcpy(To, From,
static_cast<size_t>(PlaneWidth) * PlaneHeight);
197 for (
int y = 0; y < PlaneHeight; y++)
199 memcpy(To, From,
static_cast<size_t>(PlaneWidth));
212 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Cannot clear a hardware frame");
229 unsigned char uv1 = (uv & 0xff00) >> 8;
230 unsigned char uv2 = (uv & 0x00ff);
233 for (
int row = 0; row < uv_height; ++row)
235 for (
int col = 0; col <
m_pitches[1]; col += 2)
237 buf1[col] = buf2[col] = uv1;
238 buf1[col + 1] = buf2[col + 1] = uv2;
252 unsigned char uv1 = (uv & 0xff00) >> 8;
253 unsigned char uv2 = (uv & 0x00ff);
255 for (
int row = 0; row < uv_height; ++row)
257 for (
int col = 0; col <
m_pitches[1]; col += 4)
259 buf3[col] = buf3[col + 2] = uv1;
260 buf3[col + 1] = buf3[col + 3] = uv2;
278 if (!From || (
this == From))
283 LOG(VB_GENERAL, LOG_ERR,
"Cannot copy frames of differing types");
289 LOG(VB_GENERAL, LOG_ERR,
"Invalid frame format");
296 LOG(VB_GENERAL, LOG_ERR,
"Invalid frame sizes");
302 LOG(VB_GENERAL, LOG_ERR,
"Invalid frames for copying");
310 LOG(VB_GENERAL, LOG_ERR,
"Invalid buffer size");
319 for (
uint plane = 0; plane < count; plane++)
405 case FMT_VTB:
return "VideoToolBox";
422 int adj_w = Aligned ? ((Width + Aligned - 1) & ~(Aligned - 1)) : Width;
426 int remainder = (adj_w * adj_h * bpp) % bpb;
427 return static_cast<uint>(((adj_w * adj_h * bpp) / bpb) + (remainder ? 1 : 0));
432 return static_cast<uint8_t*
>(av_malloc(Size + 64));
465 QString result = DoubleRate ?
"2x " :
"";
518 case DEINT_HIGH:
return result +
"Compensated";
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
static constexpr const char * DEINT_QUALITY_MEDIUM
void ClearBufferToBlank()
static constexpr const char * DEINT_QUALITY_HIGH
#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)
std::chrono::milliseconds m_displayTimecode
static int BitsPerPixel(VideoFrameType Type)
MythDeintType m_deinterlaceDouble
static size_t GetBufferSize(VideoFrameType Type, int Width, int Height, int Aligned=MYTH_WIDTH_ALIGNMENT)
static void CopyPlane(uint8_t *To, int ToPitch, const uint8_t *From, int FromPitch, int PlaneWidth, int PlaneHeight)
bool m_alreadyDeinterlaced
std::chrono::milliseconds m_timecode
std::vector< VideoFrameType > VideoFrameTypes
const std::array< const std::string, 8 > formats
static constexpr const char * DEINT_QUALITY_DRIVER
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 constexpr const char * DEINT_QUALITY_LOW
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 constexpr const char * DEINT_QUALITY_SHADER
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)
static constexpr uint8_t MYTH_HEIGHT_ALIGNMENT
static uint8_t * GetAlignedBuffer(size_t Size)
@ FMT_RGB32
endian dependent format, ARGB or BGRA
MythDeintType m_deinterlaceInuse
MythHDRVideoPtr m_hdrMetadata
bool CopyFrame(MythVideoFrame *From)
static bool FormatIsNV12(VideoFrameType Type)
MythDeintType m_deinterlaceSingle
bool m_deinterlaceInuse2x
std::array< uint8_t *, 4 > m_priv