caps: never lower the level ceiling when 8-bit at that level works
The 0.5.0.0 gate blocked a Main 10 tier whenever decodingInfo called it
unusable. That is wrong on a machine that decodes 8-bit 8K but not 10-bit 8K,
which is exactly the machine this was written on (measured: nvidia-vaapi-driver
decodes 8192x4096 Main 8-bit and fails to create a decoder for 8192x4096
Main 10).
browserDeviceProfile.js derives the level ceiling and the profile list from ONE
chain of Main 10 probes -- the only Main (8-bit) probes are L4.0 and L4.1. So
the reachable states are only (120,main) (123,main) (123,main|main 10)
(153,main|main 10) (183,main|main 10) (186,main|main 10). "Main up to 8K,
Main 10 only up to 4K" is not expressible. Blocking 2:183 on that machine
therefore does not spare the 10-bit file -- it drags every 8-bit 8K file down to
level 153 and transcodes the whole library. On a server that cannot transcode 8K
in real time that trades one broken file for sixty.
So a Main 10 tier is now only blocked when the SAME LEVEL is also unusable in
Main (8-bit): 8-bit probes were added at L5.1, L6.1 and L6.2 as the control. The
cost is that a device which decodes 8-bit at a level but not 10-bit still claims
10-bit there and can black-screen on such a file -- which is precisely what
40-watchdog.js exists for.
Also notes the real root cause for that machine, which is not in this plugin:
nvidia-vaapi-driver 0.0.14 has a self-referential CUVIDDECODECREATEINFO
initializer (".ulWidth = vdci.ulMaxWidth = ..."), undefined behaviour that feeds
invalid dimensions to cuvidCreateDecoder. It advertises HEVC Main 10 up to
8192x8192 but cannot create the decoder. Fixed upstream in 0.0.18 by moving the
assignments out of the initializer.
Verified against the local harness, five modes, all passing:
pc 8K unusable in both bit depths -> cap 153 -> TRANSCODE
slow 8-bit 8K ok, 10-bit 8K not -> nothing blocked -> 8-bit 8K DIRECT PLAY
quest everything ok -> DIRECT PLAY
pin 2:183 pinned -> pin wins, rest still blocked
off kill switch -> canPlayType untouched
This commit is contained in:
+73
-16
@@ -352,16 +352,39 @@
|
||||
* DirectPlay. Meta's browser-video docs recommend exactly this API over UA
|
||||
* sniffing.
|
||||
*
|
||||
* Only a definite "no" downgrades, but "no" has two shapes and both matter:
|
||||
* A tier is blocked when:
|
||||
*
|
||||
* supported === false the decoder cannot handle the format at all
|
||||
* smooth === false it can, but not in real time at that resolution and
|
||||
* frame rate -- the case a desktop with a small HEVC
|
||||
* decoder hits on 8K, where the picture never appears
|
||||
* even though the codec is "supported"
|
||||
* supported === false the decoder cannot handle the format at all
|
||||
* smooth === false it can, but not in real time at that resolution and
|
||||
* frame rate -- the "decoder exists, 8K does not work"
|
||||
* case
|
||||
*
|
||||
* Either one means the server should transcode. A tier that is only
|
||||
* `powerEfficient:false` (software decode) is NOT acted on by itself.
|
||||
* AND, for a Main 10 tier, only when the SAME LEVEL IS ALSO UNUSABLE IN MAIN
|
||||
* (8-bit). That second condition is not cosmetic; it is forced by a real
|
||||
* limitation in Jellyfin's device profile.
|
||||
*
|
||||
* browserDeviceProfile.js derives the level ceiling and the profile list from
|
||||
* ONE chain of Main 10 probes -- the only Main (8-bit) probes are L4.0 and
|
||||
* L4.1. So the reachable states are only:
|
||||
*
|
||||
* (120, main) (123, main) (123, main|main 10) (153, main|main 10)
|
||||
* (183, main|main 10) (186, main|main 10)
|
||||
*
|
||||
* "Main up to 8K, Main 10 only up to 4K" is NOT expressible. So blocking
|
||||
* 2:183 on a device that decodes 8-bit 8K but not 10-bit 8K does not just
|
||||
* spare the 10-bit file -- it drags every 8-bit 8K file down to level 153 and
|
||||
* transcodes them too. On a server that cannot transcode 8K in real time
|
||||
* (measured: 8192x4096 -> 1280x640), that trades one broken file for sixty.
|
||||
*
|
||||
* Verified on the machine this was written for: NVIDIA VAAPI decodes
|
||||
* 8192x4096 Main 8-bit fine and fails to create a decoder for 8192x4096
|
||||
* Main 10 (nvidia-vaapi-driver passes the surface bit depth straight to
|
||||
* cuvidCreateDecoder). Its whole library is 8-bit 8K, so lowering the ceiling
|
||||
* would have broken all of it.
|
||||
*
|
||||
* The cost of this rule: a device that decodes 8-bit at a level but not
|
||||
* 10-bit will still claim 10-bit at that level and can black-screen on such a
|
||||
* file. 40-watchdog.js covers exactly that, which is why it stays.
|
||||
*
|
||||
* Escape hatches, if a device reports nonsense:
|
||||
* localStorage['jfvr-cpt'] = 'off' disable the hook entirely
|
||||
@@ -369,11 +392,15 @@
|
||||
*/
|
||||
|
||||
// decodingInfo needs real dimensions; a level string does not carry them, so
|
||||
// each level is probed at the resolution and bitrate it exists for.
|
||||
// each level is probed at the resolution and bitrate it exists for. Main
|
||||
// (8-bit) is probed at the same levels as Main 10 because it is the control
|
||||
// that decides whether a level is really out of reach.
|
||||
var CODEC_PROBES = [
|
||||
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, mbps: 8, codec: 'hvc1.1.L120' },
|
||||
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.1.4.L123' },
|
||||
{ key: '1:153', name: 'Main L5.1 (4K)', w: 3840, h: 2160, fps: 60, mbps: 20, codec: 'hvc1.1.5.L153.B0' },
|
||||
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.1.6.L183.B0' },
|
||||
{ key: '1:186', name: 'Main L6.2 (8K60)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.1.6.L186.B0' },
|
||||
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.2.4.L123' },
|
||||
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, mbps: 20, codec: 'hvc1.2.4.L153' },
|
||||
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.2.4.L183' },
|
||||
@@ -445,14 +472,42 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
/** True when this tier is not usable on its own terms. */
|
||||
function tierUnusable(key) {
|
||||
var v = NS.caps.codec[key];
|
||||
return !!v && !v.error && (v.supported === false || v.smooth === false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The decision the canPlayType hook uses.
|
||||
*
|
||||
* A Main 10 tier is only blocked when the SAME LEVEL is also unusable in Main
|
||||
* (8-bit). See the long comment above CODEC_PROBES: Jellyfin's profile cannot
|
||||
* express "Main up to 8K, Main 10 up to 4K", so blocking 2:183 on a device
|
||||
* that handles 8-bit 8K would drag all of its 8-bit 8K files into transcoding.
|
||||
*/
|
||||
function shouldBlock(key, keep) {
|
||||
var v = NS.caps.codec[key];
|
||||
if (!v || v.error) return null;
|
||||
if (keep.indexOf(key) >= 0) return null;
|
||||
var own = blockReason(v, keep);
|
||||
if (!own) return null;
|
||||
var parts = key.split(':');
|
||||
if (parts[0] === '2') {
|
||||
// Control: the same level in Main (8-bit).
|
||||
if (!tierUnusable('1:' + parts[1])) return null;
|
||||
}
|
||||
return own;
|
||||
}
|
||||
|
||||
function applyVerdicts() {
|
||||
var keep = readKeepList();
|
||||
var keep = NS.caps.__keep || [];
|
||||
NS.caps.codecKept = [];
|
||||
NS.caps.codecBlocked = [];
|
||||
CODEC_PROBES.forEach(function (p) {
|
||||
var v = NS.caps.codec[p.key];
|
||||
if (!v) return;
|
||||
var why = blockReason(v, keep);
|
||||
var why = shouldBlock(p.key, keep);
|
||||
if (why) NS.caps.codecBlocked.push(p.name + ' (' + why + ')');
|
||||
else if (keep.indexOf(p.key) >= 0) NS.caps.codecKept.push(p.name);
|
||||
});
|
||||
@@ -467,9 +522,8 @@
|
||||
proto.canPlayType = function (type) {
|
||||
try {
|
||||
var key = hevcKey(type);
|
||||
var v = key && NS.caps.codec[key];
|
||||
// Only a definite "no" is acted on. Anything else is the browser's call.
|
||||
if (v && blockReason(v, NS.caps.__keep || [])) return '';
|
||||
if (key && shouldBlock(key, NS.caps.__keep || [])) return '';
|
||||
} catch (e) { /* never break the native answer */ }
|
||||
return orig.apply(this, arguments);
|
||||
};
|
||||
@@ -527,11 +581,14 @@
|
||||
var v = c.codec[p.key];
|
||||
if (!v) return ' ' + p.name.padEnd(20) + ' (pending)';
|
||||
if (v.error) return ' ' + p.name.padEnd(20) + ' error: ' + v.error;
|
||||
var why = blockReason(v, keep);
|
||||
var why = shouldBlock(p.key, keep);
|
||||
var own = blockReason(v, keep);
|
||||
var note = why ? ' <-- BLOCKED (' + why + ')' :
|
||||
(own ? ' (unusable, but kept: 8-bit at this level works)' :
|
||||
(keep.indexOf(p.key) >= 0 ? ' <-- pinned' : ''));
|
||||
return ' ' + p.name.padEnd(20) + ' supported=' + v.supported +
|
||||
' smooth=' + v.smooth + ' powerEfficient=' + v.powerEfficient +
|
||||
' [' + v.workload + ']' +
|
||||
(why ? ' <-- BLOCKED (' + why + ')' : (keep.indexOf(p.key) >= 0 ? ' <-- pinned' : ''));
|
||||
' [' + v.workload + ']' + note;
|
||||
}).join('\n');
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user