Use system FFmpeg for VP9 playback on Linux

This commit is contained in:
nmzik
2026-09-15 19:30:28 +04:00
parent acd7435d31
commit 9cf7963f44
7 changed files with 48 additions and 21 deletions
+12 -2
View File
@@ -384,6 +384,16 @@ static bool codec_is_supported_for_source(AvPlayerSourceType source_type, AVMedi
}
}
static const AVCodec* find_decoder(AVCodecID codec_id) {
const auto* decoder = avcodec_find_decoder(codec_id);
if (decoder == nullptr && codec_id == AV_CODEC_ID_VP9) {
Log::WriteToConsoleAndLog(
"WARNING: AvPlayer: The game requested VP9 video, but FFmpeg has no VP9 "
"decoder. Use FFmpeg with VP9 decoding enabled.\n");
}
return decoder;
}
struct PacketDeleter {
void operator()(AVPacket* packet) const { av_packet_free(&packet); }
};
@@ -1064,7 +1074,7 @@ private:
static_cast<int>(s->codecpar->codec_id), static_cast<uint32_t>(source_type));
return false;
}
if (avcodec_find_decoder(s->codecpar->codec_id) == nullptr) {
if (find_decoder(s->codecpar->codec_id) == nullptr) {
LOGF("\t decoder not found: stream=%d codec=%d\n", id,
static_cast<int>(s->codecpar->codec_id));
return false;
@@ -1073,7 +1083,7 @@ private:
}
bool OpenCodec(int id, AVCodecContext** out) {
auto* s = fmt->streams[id];
auto* dec = avcodec_find_decoder(s->codecpar->codec_id);
auto* dec = find_decoder(s->codecpar->codec_id);
if (dec == nullptr) {
LOGF("\t avcodec_find_decoder failed: stream=%d codec=%d\n", id,
static_cast<int>(s->codecpar->codec_id));
+11 -1
View File
@@ -38,7 +38,12 @@
#endif
extern "C" {
#include <libavutil/version.h>
#if LIBAVUTIL_VERSION_MAJOR < 61
extern const uint8_t avpriv_vga16_font[4096];
#else
const uint8_t* avpriv_vga16_font_get(void);
#endif
}
namespace Libs {
@@ -950,10 +955,15 @@ static void init_image(std::array<uint8_t, FONT_BITMAP_MAX_DIM * FONT_BITMAP_MAX
const auto width = static_cast<uint32_t>(scaled_font_width(font));
const auto height = static_cast<uint32_t>(scaled_font_height(font));
#if LIBAVUTIL_VERSION_MAJOR < 61
const auto* vga_font = avpriv_vga16_font;
#else
const auto* vga_font = avpriv_vga16_font_get();
#endif
for (uint32_t y = 0; y < height; y++) {
const uint32_t src_y = std::min<uint32_t>((y * 16u) / height, 15u);
const uint8_t row = avpriv_vga16_font[code * 16 + src_y];
const uint8_t row = vga_font[code * 16 + src_y];
for (uint32_t x = 0; x < width; x++) {
const uint32_t src_x = std::min<uint32_t>((x * 8u) / width, 7u);
if ((row & (0x80u >> src_x)) != 0) {
+5
View File
@@ -92,6 +92,11 @@ public:
[[nodiscard]] bool Initialize() {
const AVCodec* decoder = avcodec_find_decoder(GetAvCodecId(m_config.codec_type));
if (decoder == nullptr) {
if (m_config.codec_type == CODEC_TYPE_VP9) {
Log::WriteToConsoleAndLog(
"WARNING: Videodec2: The game requested VP9 video, but FFmpeg has no VP9 "
"decoder. Use FFmpeg with VP9 decoding enabled.\n");
}
LOGF("Videodec2: FFmpeg decoder is unavailable for codec type %u\n",
m_config.codec_type);
return false;