Update Windows and macOS to FFmpeg 5.0

This commit is contained in:
Cameron Gutman
2022-01-21 23:09:43 -06:00
parent ee5918cf4e
commit a58649fd10
5 changed files with 29 additions and 127 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ win32:!winrt {
CONFIG += soundio discord-rpc CONFIG += soundio discord-rpc
} }
macx { macx {
LIBS += -lssl -lcrypto -lavcodec.58 -lavutil.56 -lopus -framework SDL2 -framework SDL2_ttf LIBS += -lssl -lcrypto -lavcodec.59 -lavutil.57 -lopus -framework SDL2 -framework SDL2_ttf
LIBS += -lobjc -framework VideoToolbox -framework AVFoundation -framework CoreVideo -framework CoreGraphics -framework CoreMedia -framework AppKit -framework Metal LIBS += -lobjc -framework VideoToolbox -framework AVFoundation -framework CoreVideo -framework CoreGraphics -framework CoreMedia -framework AppKit -framework Metal
# For libsoundio # For libsoundio
@@ -83,7 +83,7 @@ void DXVA2Renderer::ffPoolDummyDelete(void*, uint8_t*)
/* Do nothing */ /* Do nothing */
} }
AVBufferRef* DXVA2Renderer::ffPoolAlloc(void* opaque, int) AVBufferRef* DXVA2Renderer::ffPoolAlloc(void* opaque, FF_POOL_SIZE_TYPE)
{ {
DXVA2Renderer* me = reinterpret_cast<DXVA2Renderer*>(opaque); DXVA2Renderer* me = reinterpret_cast<DXVA2Renderer*>(opaque);
+7 -1
View File
@@ -29,8 +29,14 @@ private:
bool isDXVideoProcessorAPIBlacklisted(); bool isDXVideoProcessorAPIBlacklisted();
void renderOverlay(Overlay::OverlayType type); void renderOverlay(Overlay::OverlayType type);
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 68, 0)
#define FF_POOL_SIZE_TYPE size_t
#else
#define FF_POOL_SIZE_TYPE int
#endif
static static
AVBufferRef* ffPoolAlloc(void* opaque, int size); AVBufferRef* ffPoolAlloc(void* opaque, FF_POOL_SIZE_TYPE size);
static static
void ffPoolDummyDelete(void*, uint8_t*); void ffPoolDummyDelete(void*, uint8_t*);
+19 -123
View File
@@ -178,101 +178,15 @@ public:
return; return;
} }
// Strip the attachments added by VT. They are likely wrong. // FFmpeg 5.0+ sets the CVPixelBuffer attachments properly now, so we don't have to
CVBufferRemoveAllAttachments(pixBuf); // fix them up ourselves (except CGColorSpace and PAR attachments).
CVBufferSetAttachment(pixBuf, // The VideoToolbox decoder attaches pixel aspect ratio information to the CVPixelBuffer
kCVImageBufferChromaSubsamplingKey, // which will rescale the video stream in accordance with the host display resolution
kCVImageBufferChromaSubsampling_420, // to preserve the original aspect ratio of the host desktop. This behavior currently
kCVAttachmentMode_ShouldPropagate); // differs from the behavior of all other Moonlight Qt renderers, so we will strip
// these attachments for consistent behavior.
switch (frame->chroma_location) { CVBufferRemoveAttachment(pixBuf, kCVImageBufferPixelAspectRatioKey);
case AVCHROMA_LOC_LEFT:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_Left,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCHROMA_LOC_CENTER:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_Center,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCHROMA_LOC_TOPLEFT:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_TopLeft,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCHROMA_LOC_TOP:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_Top,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCHROMA_LOC_BOTTOMLEFT:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_BottomLeft,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCHROMA_LOC_BOTTOM:
CVBufferSetAttachment(pixBuf,
kCVImageBufferChromaLocationTopFieldKey,
kCVImageBufferChromaLocation_Bottom,
kCVAttachmentMode_ShouldPropagate);
break;
default:
break;
}
switch (frame->color_primaries) {
case AVCOL_PRI_BT709:
CVBufferSetAttachment(pixBuf,
kCVImageBufferColorPrimariesKey,
kCVImageBufferColorPrimaries_ITU_R_709_2,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_PRI_SMPTE170M:
CVBufferSetAttachment(pixBuf,
kCVImageBufferColorPrimariesKey,
kCVImageBufferColorPrimaries_SMPTE_C,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_PRI_BT2020:
CVBufferSetAttachment(pixBuf,
kCVImageBufferColorPrimariesKey,
kCVImageBufferColorPrimaries_ITU_R_2020,
kCVAttachmentMode_ShouldPropagate);
break;
default:
break;
}
switch (frame->color_trc) {
case AVCOL_TRC_BT709:
case AVCOL_TRC_SMPTE170M:
CVBufferSetAttachment(pixBuf,
kCVImageBufferTransferFunctionKey,
kCVImageBufferTransferFunction_ITU_R_709_2,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_TRC_BT2020_10:
CVBufferSetAttachment(pixBuf,
kCVImageBufferTransferFunctionKey,
kCVImageBufferTransferFunction_ITU_R_2020,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_TRC_SMPTE2084:
CVBufferSetAttachment(pixBuf,
kCVImageBufferTransferFunctionKey,
kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ,
kCVAttachmentMode_ShouldPropagate);
break;
default:
break;
}
// Reset m_ColorSpace if the colorspace changes. This can happen when // Reset m_ColorSpace if the colorspace changes. This can happen when
// a game enters HDR mode (Rec 601 -> Rec 2020). // a game enters HDR mode (Rec 601 -> Rec 2020).
@@ -282,39 +196,21 @@ public:
m_ColorSpace = nullptr; m_ColorSpace = nullptr;
} }
m_LastAvColorSpace = frame->colorspace; switch (frame->colorspace) {
} case AVCOL_SPC_BT709:
switch (frame->colorspace) {
case AVCOL_SPC_BT709:
if (m_ColorSpace == nullptr) {
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709); m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
} break;
CVBufferSetAttachment(pixBuf, case AVCOL_SPC_BT2020_NCL:
kCVImageBufferYCbCrMatrixKey,
kCVImageBufferYCbCrMatrix_ITU_R_709_2,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_SPC_BT2020_NCL:
if (m_ColorSpace == nullptr) {
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
} break;
CVBufferSetAttachment(pixBuf, case AVCOL_SPC_SMPTE170M:
kCVImageBufferYCbCrMatrixKey,
kCVImageBufferYCbCrMatrix_ITU_R_2020,
kCVAttachmentMode_ShouldPropagate);
break;
case AVCOL_SPC_SMPTE170M:
if (m_ColorSpace == nullptr) {
m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
break;
default:
break;
} }
CVBufferSetAttachment(pixBuf,
kCVImageBufferYCbCrMatrixKey, m_LastAvColorSpace = frame->colorspace;
kCVImageBufferYCbCrMatrix_ITU_R_601_4,
kCVAttachmentMode_ShouldPropagate);
break;
default:
break;
} }
if (m_ColorSpace != nullptr) { if (m_ColorSpace != nullptr) {
+1 -1
Submodule libs updated: d0ed5c99af...5ef8a666eb