summaryrefslogtreecommitdiff
path: root/kpipewire/5.27-magicyuv-yuv444.patch
blob: c742afc699fc4f20b68658535cdefe5f80a7c6d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From e943d0ca542b4e4f4c458165fdcdc8e413c3d2a5 Mon Sep 17 00:00:00 2001
From: Terin Stock <terinjokes@gmail.com>
Date: Mon, 22 Apr 2024 00:29:34 +0200
Subject: [PATCH] Record: support MagicYUV 4:4:4

The two codecs currently supported, H264 and WebM are not suitable for
recording with minimal CPU overhead and losslessly for farther editing
or archiving.

This changeset adds support for recording in MagicYUV 4:4:4 in a
Matroska container. This is suitably fast and satisfies the lossless
goal, while still having some compression. These can be transcoded to
FFV1 with no quality loss offline.
---
 src/pipewirerecord.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/pipewirerecord.cpp b/src/pipewirerecord.cpp
index ac8132e..232bbd6 100644
--- a/src/pipewirerecord.cpp
+++ b/src/pipewirerecord.cpp
@@ -301,10 +301,14 @@ void PipeWireRecordProduce::setupStream()
     m_avCodecContext->height = size.height();
     m_avCodecContext->max_b_frames = 1;
     m_avCodecContext->gop_size = 100;
-    if (m_codec->pix_fmts && m_codec->pix_fmts[0] > 0) {
-        m_avCodecContext->pix_fmt = m_codec->pix_fmts[0];
+    if (QStringLiteral("magicyuv") == QString::fromUtf8(m_encoder)) {
+        m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV444P;
     } else {
-        m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
+        if (m_codec->pix_fmts && m_codec->pix_fmts[0] > 0) {
+            m_avCodecContext->pix_fmt = m_codec->pix_fmts[0];
+        } else {
+            m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
+        }
     }
     m_avCodecContext->time_base = AVRational{1, 1000};
 
@@ -462,7 +466,7 @@ QByteArray PipeWireRecord::encoder() const
 
 QList<QByteArray> PipeWireRecord::suggestedEncoders() const
 {
-    QList<QByteArray> ret = {"libvpx", "libx264"};
+    QList<QByteArray> ret = {"libvpx", "libx264", "magicyuv"};
     std::remove_if(ret.begin(), ret.end(), [](const QByteArray &encoder) {
         return !avcodec_find_encoder_by_name(encoder.constData());
     });
-- 
2.43.2