Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Sharpness (CAS) in the in-game menu; 1080p as a Tizen TV for tests

Rafael Abud Ferreira35dade4ddeb8
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 035a7af..1fa0953 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -622,12 +622,11 @@ int main(int argc, char** argv) {
stbi_write_png(path.c_str(), 1920, 1080, 4, frame.data(), 1920 * 4);
std::printf("wrote %s\n", path.c_str());
};
- menu.open(0, true);
+ menu.open(0, true, 2);
save("menu", menu.renderMenu(info), ui::StreamMenu::kMenuX, ui::StreamMenu::kMenuY, 235);
ui::NavInput n;
n.down = true;
- menu.handle(n);
- menu.handle(n);
+ for (int i = 0; i < 3; ++i) menu.handle(n);
n = {};
n.right = true;
menu.handle(n); // 1080p -> 1440p
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 19b3b00..2d940bf 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -127,7 +127,8 @@ void updateTextInput(app::StreamPlayer* player) {
// rumbletest (rumbles the pad for 1.5 s at start), detailtest (opens a game to
// buy far down the list instead of playing, saves detail.ppm), imetest (opens
// the system keyboard on the home screen), menutest (in the game: the menu,
-// 720p, back to 1080p), res=720p|1080p|1440p (instead of the setting).
+// 720p, back to 1080p), res=720p|1080p|1080p-hq|1440p and sharp=0..3 (instead
+// of the settings).
// The title "BENCH" decodes <dataDir>/sample.h264 instead.
std::string g_autoplayTitle;
@@ -140,6 +141,7 @@ bool g_autoplayLibraryTest = false; // open "Your games", save it at 4 s and 25
bool g_autoplayImeTest = false; // open the system keyboard on the home screen
bool g_autoplayMenuTest = false; // in the game: open the menu, switch to 720p
int g_decodeThreads = 1;
+int g_autoplaySharpness = -1; // sharp=0..3: instead of the setting
std::string g_autoplayResolution; // res=720p|1080p|1440p: instead of the setting
std::atomic<bool> g_syntheticA{false};
@@ -166,6 +168,7 @@ void loadAutoplay() {
if (opt == "imetest") g_autoplayImeTest = true;
if (opt == "menutest") g_autoplayMenuTest = true;
if (opt.rfind("res=", 0) == 0) g_autoplayResolution = opt.substr(4);
+ if (opt.rfind("sharp=", 0) == 0) g_autoplaySharpness = std::atoi(opt.c_str() + 6);
if (opt.rfind("threads=", 0) == 0) g_decodeThreads = std::atoi(opt.c_str() + 8);
}
g_autoplayTitle = title;
@@ -339,9 +342,10 @@ std::string play(auth::AuthManager& am, xcloud::GssvClient& gssv, const ui::Game
{
std::lock_guard<std::mutex> lock(g_settingsMutex);
const std::string& res = g_autoplayResolution.empty() ? g_settings.resolution : g_autoplayResolution;
- gssv.setResolution(res == "720p" ? xcloud::Resolution::P720
- : res == "1440p" ? xcloud::Resolution::P1440
- : xcloud::Resolution::P1080);
+ gssv.setResolution(res == "720p" ? xcloud::Resolution::P720
+ : res == "1440p" ? xcloud::Resolution::P1440
+ : res == "1080p-hq" ? xcloud::Resolution::P1080HQ
+ : xcloud::Resolution::P1080);
const xcloud::Region* region = gssv.session().defaultRegion();
const std::string& wanted = regionName.empty() ? g_settings.region : regionName;
for (const auto& r : gssv.session().regions)
@@ -737,6 +741,9 @@ int main(int argc, char** argv) {
const app::StreamPlayer* overlayPlayer = nullptr;
int streamResolution = 0; // as SettingsChoice::resolution
bool showStats = false, overlayShown = false;
+ int sharpness = 0; // 0..3, as Settings::sharpness
+ // How much CAS each sharpness level mixes in (display::setSharpness).
+ static constexpr int kSharpAmount[] = {0, 96, 176, 256};
bool padReleased = true; // false from the menu/keyboard until the buttons are let go
uint32_t overlaySeq = 0; // g_infoSeq + 1 when drawn; 0 = redraw
uint64_t homeSince = 0, launchSince = 0;
@@ -768,19 +775,19 @@ int main(int argc, char** argv) {
bool menuCombo = pad.btnOptions && pad.btnTouchpad && !(prev.btnOptions && prev.btnTouchpad);
prev = pad;
if (g_autoplayMenuTest && g_ui->screen() == ui::Screen::Streaming) {
- // Menu, down twice to the resolution, left to 720p, accept; at
+ // Menu, down three times to the resolution, left to 720p, accept; at
// 35 s right (back to 1080p) and accept.
static uint64_t since = 0;
static int step = 0;
if (!since) since = now;
- const uint64_t at[] = {12000, 13000, 13500, 14000, 14500, 35000, 35500};
- if (step < 7 && now - since >= at[step]) {
+ const uint64_t at[] = {12000, 13000, 13300, 13600, 14000, 14500, 35000, 35500};
+ if (step < 8 && now - since >= at[step]) {
nav = ui::NavInput{};
if (step == 0) menuCombo = true;
- if (step == 1 || step == 2) nav.down = true;
- if (step == 3) nav.left = true;
- if (step == 4 || step == 6) nav.accept = true;
- if (step == 5) nav.right = true;
+ if (step >= 1 && step <= 3) nav.down = true;
+ if (step == 4) nav.left = true;
+ if (step == 5 || step == 7) nav.accept = true;
+ if (step == 6) nav.right = true;
XC_LOGI("autoplay: menu step %d", step);
++step;
}
@@ -794,6 +801,8 @@ int main(int argc, char** argv) {
std::lock_guard<std::mutex> settingsLock(g_settingsMutex);
streamResolution = g_settings.resolution == "720p" ? 1 : g_settings.resolution == "1440p" ? 2 : 0;
showStats = g_settings.streamStats;
+ sharpness = g_autoplaySharpness >= 0 ? g_autoplaySharpness : g_settings.sharpness;
+ display::setSharpness(kSharpAmount[std::clamp(sharpness, 0, 3)]);
overlaySeq = 0;
}
if (g_player) {
@@ -801,7 +810,7 @@ int main(int argc, char** argv) {
// OPTIONS + TOUCHPAD opens the menu (and closes it again).
bool wasOpen = menu.isOpen();
if (!wasOpen && menuCombo && g_keyboardFor.empty()) {
- menu.open(streamResolution, showStats);
+ menu.open(streamResolution, showStats, sharpness);
overlaySeq = 0;
} else if (wasOpen) {
switch (menu.handle(nav)) {
@@ -813,6 +822,14 @@ int main(int argc, char** argv) {
: streamResolution == 2 ? "1440"
: "1080HQ");
break;
+ case ui::MenuAction::Sharpness: {
+ sharpness = menu.sharpness();
+ display::setSharpness(kSharpAmount[sharpness]);
+ std::lock_guard<std::mutex> settingsLock(g_settingsMutex);
+ g_settings.sharpness = sharpness;
+ g_settings.save(settingsPath());
+ break;
+ }
case ui::MenuAction::Stats: {
showStats = menu.statsOn();
std::lock_guard<std::mutex> settingsLock(g_settingsMutex);
diff --git a/src/app/settings.cpp b/src/app/settings.cpp
index 0c2fe7c..ae57c2c 100644
--- a/src/app/settings.cpp
+++ b/src/app/settings.cpp
@@ -5,6 +5,8 @@
#include "platform/platform.h"
#include "util/json.h"
+#include <algorithm>
+
namespace xc::app {
bool Settings::load(const std::string& path) {
@@ -21,6 +23,7 @@ bool Settings::load(const std::string& path) {
if (!id.str().empty()) hidden.push_back(id.str());
librarySort = (*j)["librarySort"].str(librarySort);
streamStats = (*j)["streamStats"].asBool(streamStats);
+ sharpness = static_cast<int>(std::clamp<int64_t>((*j)["sharpness"].asInt(sharpness), 0, 3));
regionRtt.clear();
for (const auto& [name, ms] : (*j)["regionRtt"].members())
if (ms.asInt() > 0) regionRtt[name] = static_cast<int>(ms.asInt());
@@ -40,6 +43,7 @@ bool Settings::save(const std::string& path) const {
v.set("hidden", hiddenIds);
v.set("librarySort", librarySort);
v.set("streamStats", streamStats);
+ v.set("sharpness", sharpness);
return platform::writeFileAtomic(path, v.dump());
}
diff --git a/src/app/settings.h b/src/app/settings.h
index 3ab74be..6c33972 100644
--- a/src/app/settings.h
+++ b/src/app/settings.h
@@ -21,6 +21,8 @@ struct Settings {
std::string librarySort = "recent";
// The statistics line over the game (in-game menu).
bool streamStats = false;
+ // Sharpening of the game picture: 0 off, 1..3 low, medium, high.
+ int sharpness = 0;
bool load(const std::string& path);
bool save(const std::string& path) const;
diff --git a/src/app/stream_player.cpp b/src/app/stream_player.cpp
index 843e61b..f21f526 100644
--- a/src/app/stream_player.cpp
+++ b/src/app/stream_player.cpp
@@ -284,11 +284,13 @@ struct StreamPlayer::Impl {
// the plain tier the session asks for first holds.
switch (gssv.resolution()) {
case xcloud::Resolution::P1440: opts.resolutionAlias = "1440"; break;
- case xcloud::Resolution::P1080: opts.resolutionAlias = "1080HQ"; break;
+ case xcloud::Resolution::P1080:
+ case xcloud::Resolution::P1080HQ: opts.resolutionAlias = "1080HQ"; break;
case xcloud::Resolution::P720: opts.resolutionAlias = "720HQ"; break;
}
opts.maxBitrate = gssv.resolution() == xcloud::Resolution::P720 ? 12000000
: gssv.resolution() == xcloud::Resolution::P1440 ? 40000000
+ : gssv.resolution() == xcloud::Resolution::P1080HQ ? 30000000
: 25000000;
if (const char* loss = std::getenv("XC_SIM_LOSS")) opts.simulatedVideoLoss = std::atoi(loss);
session = std::make_unique<stream::StreamSession>(gssv, cb, opts);
diff --git a/src/display/display.cpp b/src/display/display.cpp
index 6ad1224..9ff2e53 100644
--- a/src/display/display.cpp
+++ b/src/display/display.cpp
@@ -6,6 +6,7 @@
#include <algorithm>
#include <array>
+#include <cmath>
#include <atomic>
#include <condition_variable>
#include <cstring>
@@ -236,6 +237,50 @@ struct YuvJob {
inline uint8_t clamp8(int v) { return static_cast<uint8_t>(v < 0 ? 0 : v > 255 ? 255 : v); }
+// Sharpening: AMD FidelityFX CAS on the luma, cross-shaped (Better xCloud's
+// "Clarity boost"). How much of it is mixed in, of 256; 0 = off.
+std::atomic<int> g_sharpness{0};
+
+// CAS per pixel, by "amplitude" (0..256: how far the neighbourhood is from
+// clipping): the neighbour weight w (negative, 12-bit fixed point) and
+// 1 / (1 + 4w) (14-bit). Peak 5.6 = contrast 0.8, as Better xCloud.
+struct CasTable {
+ int32_t weight[257], norm[257]; // 12-bit, 14-bit
+ uint32_t recip[256]; // 65536 / max
+ CasTable() {
+ for (int a = 0; a <= 256; ++a) {
+ double w = -std::sqrt(a / 256.0) / 5.6;
+ weight[a] = static_cast<int32_t>(std::lround(w * 4096));
+ norm[a] = static_cast<int32_t>(std::lround(16384 / (1 + 4 * w)));
+ }
+ recip[0] = 0;
+ for (int m = 1; m < 256; ++m) recip[m] = 65536u / m;
+ }
+};
+const CasTable& casTable() {
+ static const CasTable t;
+ return t;
+}
+
+// The luma at (sx, sy), sharpened.
+inline int sharpenedLuma(const YuvJob& job, unsigned sx, unsigned sy, int amount) {
+ const uint8_t* row = job.y + sy * job.strideY;
+ int e = row[sx];
+ int l = row[sx > 0 ? sx - 1 : sx];
+ int r = row[sx + 1 < static_cast<unsigned>(job.width) ? sx + 1 : sx];
+ int u = (sy > 0 ? row - job.strideY : row)[sx];
+ int d = (sy + 1 < static_cast<unsigned>(job.height) ? row + job.strideY : row)[sx];
+ int mn = std::min(std::min(std::min(l, r), std::min(u, d)), e);
+ int mx = std::max(std::max(std::max(l, r), std::max(u, d)), e);
+ if (mx == 0) return e;
+ const CasTable& cas = casTable();
+ int amp = static_cast<int>((static_cast<uint32_t>(std::min(mn, 255 - mx)) * 256u * cas.recip[mx]) >> 16);
+ if (amp > 256) amp = 256;
+ int num = (e << 12) + (l + r + u + d) * cas.weight[amp]; // (e + w * window), 12-bit
+ int sharp = ((num >> 6) * cas.norm[amp]) >> 20;
+ return e + (((sharp - e) * amount) >> 8);
+}
+
void convertTiles(const YuvJob& job, unsigned first, unsigned last) {
const TileOrder& order = tileOrder();
for (unsigned t = first; t < last; ++t) {
@@ -246,6 +291,7 @@ void convertTiles(const YuvJob& job, unsigned first, unsigned last) {
if (ov && (static_cast<int>(tx * 128) >= ov->x + ov->w || static_cast<int>(tx * 128 + 128) <= ov->x ||
static_cast<int>(ty * 128) >= ov->y + ov->h || static_cast<int>(ty * 128 + 128) <= ov->y))
ov = nullptr;
+ const int sharpness = g_sharpness.load(std::memory_order_relaxed);
for (unsigned i = 0; i < 16384; ++i) {
unsigned x = tx * 128 + order.dx[i];
unsigned y = ty * 128 + order.dy[i];
@@ -254,8 +300,9 @@ void convertTiles(const YuvJob& job, unsigned first, unsigned last) {
continue;
}
unsigned sx = job.srcX[x], sy = job.srcY[y];
+ int luma = sharpness ? sharpenedLuma(job, sx, sy, sharpness) : job.y[sy * job.strideY + sx];
// BT.709 limited range, 10-bit fixed point.
- int c = (static_cast<int>(job.y[sy * job.strideY + sx]) - 16) * 1192;
+ int c = (luma - 16) * 1192;
const uint8_t* u0 = job.u + job.cy0[y] * job.strideU;
const uint8_t* u1 = job.u + job.cy1[y] * job.strideU;
const uint8_t* v0 = job.v + job.cy0[y] * job.strideV;
@@ -284,10 +331,14 @@ void convertTiles(const YuvJob& job, unsigned first, unsigned last) {
}
// A few persistent workers that split the tiles of one picture.
+// Half the cores, up to 8: with sharpening on, 4 couldn't keep up at 60 fps.
+constexpr unsigned kMaxWorkers = 8;
class TilePool {
public:
TilePool() {
- unsigned n = std::max(1u, std::min(4u, std::thread::hardware_concurrency() / 2));
+ unsigned cores = std::thread::hardware_concurrency();
+ unsigned n = std::max(1u, std::min(kMaxWorkers, cores / 2));
+ XC_LOGI("display: %u cores, %u conversion threads", cores, n);
for (unsigned i = 0; i < n; ++i) {
workers_.emplace_back();
platform::startThread(workers_.back(), [this, i, n] { loop(i, n); }, 256u << 10);
@@ -434,6 +485,8 @@ bool drawYuv420(const uint8_t* y, const uint8_t* u, const uint8_t* v, int stride
return true;
}
+void setSharpness(int amount) { g_sharpness = std::clamp(amount, 0, 256); }
+
void setOverlay(const uint32_t* pixels, int x, int y, int w, int h, uint8_t opacity) {
std::shared_ptr<const Overlay> next;
if (pixels && w > 0 && h > 0)
@@ -459,6 +512,7 @@ void present() {}
bool drawYuv420(const uint8_t*, const uint8_t*, const uint8_t*, int, int, int, int, int, bool) { return true; }
void drawRgba(const uint32_t*) {}
void setOverlay(const uint32_t*, int, int, int, int, uint8_t) {}
+void setSharpness(int) {}
bool readBackRgb(std::vector<uint8_t>&) { return false; }
} // namespace xc::display
diff --git a/src/display/display.h b/src/display/display.h
index 782875b..602c56f 100644
--- a/src/display/display.h
+++ b/src/display/display.h
@@ -34,6 +34,9 @@ bool drawYuv420(const uint8_t* y, const uint8_t* u, const uint8_t* v, int stride
// `opacity`. Null `pixels` removes it. Any thread.
void setOverlay(const uint32_t* pixels, int x, int y, int w, int h, uint8_t opacity);
+// Sharpening of the video (drawYuv420), 0 = off .. 256 = full CAS.
+void setSharpness(int amount);
+
// The back buffer last drawn, untiled, as 8-bit RGB rows (diagnostics:
// what the TV shows). False without a display.
bool readBackRgb(std::vector<uint8_t>& rgb);
diff --git a/src/media/decoder.cpp b/src/media/decoder.cpp
index f4bab8b..ba1bf33 100644
--- a/src/media/decoder.cpp
+++ b/src/media/decoder.cpp
@@ -172,6 +172,10 @@ bool VideoDecoder::decode(const uint8_t* data, size_t len, Picture& out, uint32_
out.strideV = frame_->linesize[2];
out.width = frame_->width;
out.height = frame_->height;
+ if (!profileLogged_) {
+ profileLogged_ = true;
+ XC_LOGI("h264 stream: profile %d, level %d", ctx_->profile, ctx_->level);
+ }
out.tag = frame_->pts == AV_NOPTS_VALUE ? 0 : static_cast<uint32_t>(frame_->pts);
return true;
}
diff --git a/src/media/decoder.h b/src/media/decoder.h
index 5805b71..507ca6b 100644
--- a/src/media/decoder.h
+++ b/src/media/decoder.h
@@ -59,6 +59,7 @@ private:
AVFrame* frame_ = nullptr;
AVPacket* packet_ = nullptr;
bool needsKeyframe_ = true;
+ bool profileLogged_ = false;
bool pending_ = false;
int failuresLogged_ = 0;
};
diff --git a/src/ui/stream_menu.cpp b/src/ui/stream_menu.cpp
index 86121c7..0f8879e 100644
--- a/src/ui/stream_menu.cpp
+++ b/src/ui/stream_menu.cpp
@@ -29,9 +29,10 @@ std::string fmt(const char* f, double v) {
} // namespace
-void StreamMenu::open(int resolution, bool stats) {
+void StreamMenu::open(int resolution, bool stats, int sharpness) {
open_ = true;
stats_ = stats;
+ sharpness_ = sharpness;
selected_ = Resume;
resolution_ = applied_ = resolution;
resolutionAsked_ = false;
@@ -52,6 +53,10 @@ MenuAction StreamMenu::handle(const NavInput& in) {
pos = in.left ? (pos + 2) % 3 : (pos + 1) % 3;
resolution_ = kResolutionOrder[pos];
}
+ if ((selected_ == Sharpness && (in.left || in.right)) || (selected_ == Sharpness && in.accept)) {
+ sharpness_ = in.left ? (sharpness_ + 3) % 4 : (sharpness_ + 1) % 4;
+ return MenuAction::Sharpness;
+ }
if (selected_ == Stats && (in.left || in.right)) {
stats_ = !stats_;
return MenuAction::Stats;
@@ -87,12 +92,18 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {
int ty = fonts_.semibold.centeredY(row.y, row.h, kPx);
const char* label = i == Resume ? tr(Str::MenuResume)
: i == Stats ? tr(Str::MenuStats)
+ : i == Sharpness ? tr(Str::MenuSharpness)
: i == Resolution ? tr(Str::MenuResolution)
: i == Refresh ? tr(Str::MenuRefresh)
: tr(Str::MenuLeave);
fonts_.semibold.draw(c, label, row.x + 16, ty, kPx, fg);
std::string value;
if (i == Stats) value = tr(stats_ ? Str::On : Str::Off);
+ if (i == Sharpness) {
+ static constexpr Str kLevels[] = {Str::SharpOff, Str::SharpLow, Str::SharpMedium, Str::SharpHigh};
+ value = tr(kLevels[sharpness_]);
+ if (sel) value = "< " + value + " >";
+ }
if (i == Resolution) {
value = resolutionName(resolution_);
if (sel) value = "< " + value + " >";
diff --git a/src/ui/stream_menu.h b/src/ui/stream_menu.h
index 4a3f374..0eef59f 100644
--- a/src/ui/stream_menu.h
+++ b/src/ui/stream_menu.h
@@ -21,34 +21,37 @@ struct StreamInfo {
int width = 0, height = 0; // of the decoded picture
};
-enum class MenuAction { None, Close, Leave, Refresh, Resolution, Stats };
+enum class MenuAction { None, Close, Leave, Refresh, Resolution, Stats, Sharpness };
class StreamMenu {
public:
- static constexpr int kMenuW = 620, kMenuH = 780;
+ static constexpr int kMenuW = 620, kMenuH = 840;
static constexpr int kMenuX = 80, kMenuY = (1080 - kMenuH) / 2;
static constexpr int kStatsX = 32, kStatsY = 28;
explicit StreamMenu(const Fonts& fonts) : fonts_(fonts) {}
// `resolution` as SettingsChoice::resolution (0 = 1080p, 1 = 720p, 2 = 1440p).
- void open(int resolution, bool stats);
+ // `sharpness` 0 = off, 1..3 = low, medium, high.
+ void open(int resolution, bool stats, int sharpness = 0);
void close() { open_ = false; }
bool isOpen() const { return open_; }
MenuAction handle(const NavInput& in);
int resolution() const { return resolution_; }
bool statsOn() const { return stats_; }
+ int sharpness() const { return sharpness_; }
Canvas renderMenu(const StreamInfo& info) const;
Canvas renderStats(const StreamInfo& info) const;
private:
- enum Item { Resume, Stats, Resolution, Refresh, Leave, ItemCount };
+ enum Item { Resume, Stats, Sharpness, Resolution, Refresh, Leave, ItemCount };
const Fonts& fonts_;
bool open_ = false, stats_ = false;
int selected_ = Resume;
int resolution_ = 0, applied_ = 0;
+ int sharpness_ = 0;
bool resolutionAsked_ = false;
};
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index 45e9932..e785bab 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -129,6 +129,11 @@ constexpr Column kEnglish = {
"Region", // StatRegion
"Decoding", // StatDecode
"The server may keep the current quality", // ResolutionNote
+ "Sharpness", // MenuSharpness
+ "Off", // SharpOff
+ "Low", // SharpLow
+ "Medium", // SharpMedium
+ "High", // SharpHigh
};
constexpr Column kPortugueseBR = {
@@ -228,6 +233,11 @@ constexpr Column kPortugueseBR = {
"Região",
"Decodificação",
"O servidor pode manter a qualidade atual",
+ "Nitidez",
+ "Desligada",
+ "Baixa",
+ "Média",
+ "Alta",
};
constexpr Column kSpanish = {
@@ -327,6 +337,11 @@ constexpr Column kSpanish = {
"Región",
"Decodificación",
"El servidor puede mantener la calidad actual",
+ "Nitidez",
+ "Desactivada",
+ "Baja",
+ "Media",
+ "Alta",
};
constexpr Column kFrench = {
@@ -426,6 +441,11 @@ constexpr Column kFrench = {
"Région",
"Décodage",
"Le serveur peut conserver la qualité actuelle",
+ "Netteté",
+ "Désactivée",
+ "Faible",
+ "Moyenne",
+ "Élevée",
};
constexpr Column kGerman = {
@@ -525,6 +545,11 @@ constexpr Column kGerman = {
"Region",
"Dekodierung",
"Der Server behält eventuell die aktuelle Qualität bei",
+ "Schärfe",
+ "Aus",
+ "Niedrig",
+ "Mittel",
+ "Hoch",
};
constexpr Column kItalian = {
@@ -624,6 +649,11 @@ constexpr Column kItalian = {
"Regione",
"Decodifica",
"Il server potrebbe mantenere la qualità attuale",
+ "Nitidezza",
+ "Disattivata",
+ "Bassa",
+ "Media",
+ "Alta",
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 11b218e..10872c0 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -106,6 +106,11 @@ enum class Str {
StatRegion,
StatDecode,
ResolutionNote, // the server may not grant the tier asked for
+ MenuSharpness, // sharpening filter over the video
+ SharpOff,
+ SharpLow,
+ SharpMedium,
+ SharpHigh,
Count
};
diff --git a/src/xcloud/gssv.cpp b/src/xcloud/gssv.cpp
index 12f9310..ff82dde 100644
--- a/src/xcloud/gssv.cpp
+++ b/src/xcloud/gssv.cpp
@@ -100,8 +100,55 @@ const std::string& deviceInfo(Resolution res) {
v.set("dev", dev);
return v.dump();
}();
+ // 1080p HQ: the web client on a Tizen TV with a 4K panel, as Better
+ // xCloud sends it.
+ static const std::string tv = [] {
+ json::Value env = json::Value::object();
+ env.set("clientAppId", "www.xbox.com");
+ env.set("clientAppType", "browser");
+ env.set("clientAppVersion", "26.1.97");
+ env.set("clientSdkVersion", "10.3.7");
+ env.set("httpEnvironment", "prod");
+ env.set("sdkInstallId", "");
+ json::Value app = json::Value::object();
+ app.set("env", env);
+ json::Value os = json::Value::object();
+ os.set("name", "tizen");
+ os.set("ver", "22631.2715");
+ os.set("platform", "desktop");
+ json::Value hw = json::Value::object();
+ hw.set("make", "Microsoft");
+ hw.set("model", "unknown");
+ hw.set("sdktype", "web");
+ json::Value browser = json::Value::object();
+ browser.set("browserName", "chrome");
+ browser.set("browserVersion", "140.0.3485.54");
+ json::Value dims = json::Value::object();
+ dims.set("widthInPixels", 4096);
+ dims.set("heightInPixels", 2160);
+ json::Value dpi = json::Value::object();
+ dpi.set("dpiX", 1);
+ dpi.set("dpiY", 1);
+ json::Value display = json::Value::object();
+ display.set("dimensions", dims);
+ display.set("pixelDensity", dpi);
+ json::Value dev = json::Value::object();
+ dev.set("os", os);
+ dev.set("hw", hw);
+ dev.set("browser", browser);
+ dev.set("displayInfo", display);
+ json::Value v = json::Value::object();
+ v.set("appInfo", app);
+ v.set("dev", dev);
+ return v.dump();
+ }();
static const std::string hd = build(true), sd = build(false);
- return res == Resolution::P720 ? sd : res == Resolution::P1440 ? qhd : hd;
+ switch (res) {
+ case Resolution::P720: return sd;
+ case Resolution::P1440: return qhd;
+ case Resolution::P1080HQ: return tv;
+ default: return hd;
+ }
}
std::string describe(const net::Response& r) {
@@ -305,7 +352,9 @@ bool GssvClient::startSession(const std::string& titleId, const std::string& loc
settings.set("useIceConnection", false);
settings.set("timezoneOffsetMinutes", 0);
settings.set("sdkType", "web");
- settings.set("osName", resolution_ == Resolution::P720 ? "android" : "windows");
+ settings.set("osName", resolution_ == Resolution::P720 ? "android"
+ : resolution_ == Resolution::P1080HQ ? "tizen"
+ : "windows");
json::Value body = json::Value::object();
body.set("clientSessionId", "");
diff --git a/src/xcloud/gssv.h b/src/xcloud/gssv.h
index fd92c67..12854b2 100644
--- a/src/xcloud/gssv.h
+++ b/src/xcloud/gssv.h
@@ -57,7 +57,9 @@ struct IceCandidate {
// Stream resolution the service is asked for. It decides from the device the
// client claims to be: a Windows desktop gets 1080p, other devices 720p.
-enum class Resolution { P1080, P720, P1440 };
+// P1080HQ: 1080p as a Samsung TV (Tizen) asks for it, which the service
+// streams at a higher bitrate (Better xCloud's "1080p (HQ)").
+enum class Resolution { P1080, P720, P1440, P1080HQ };
class GssvClient {
public:
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index ad9af94..95904dd 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -197,14 +197,15 @@ static void testStreamMenu() {
CHECK(press([](xc::ui::NavInput& n) { n.right = true; }) == MenuAction::Stats);
CHECK(menu.statsOn());
press([](xc::ui::NavInput& n) { n.down = true; });
+ CHECK(press([](xc::ui::NavInput& n) { n.left = true; }) == MenuAction::Sharpness); // off -> high
+ CHECK(menu.sharpness() == 3);
+ press([](xc::ui::NavInput& n) { n.down = true; });
press([](xc::ui::NavInput& n) { n.left = true; }); // 1080p -> 720p
CHECK(menu.resolution() == 1);
press([](xc::ui::NavInput& n) { n.left = true; }); // wraps to 1440p
CHECK(menu.resolution() == 2);
CHECK(press([](xc::ui::NavInput& n) { n.accept = true; }) == MenuAction::Resolution);
- press([](xc::ui::NavInput& n) { n.up = true; });
- press([](xc::ui::NavInput& n) { n.up = true; });
- press([](xc::ui::NavInput& n) { n.up = true; }); // wraps to "Leave game"
+ for (int i = 0; i < 4; ++i) press([](xc::ui::NavInput& n) { n.up = true; }); // wraps to "Leave game"
CHECK(press([](xc::ui::NavInput& n) { n.accept = true; }) == MenuAction::Leave);
CHECK(!menu.isOpen());
menu.open(1, true);