Skip to content

Commit

Permalink
fix: av1 codecs string (jellyfin#11280)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com>
  • Loading branch information
2 people authored and SourSulfur committed Apr 17, 2024
1 parent 28739f1 commit b57747b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static string GetH265String(string? profile, int level)
/// <returns>The AV1 codec string.</returns>
public static string GetAv1String(string? profile, int level, bool tierFlag, int bitDepth)
{
// https://aomedia.org/av1/specification/annex-a/
// https://aomediacodec.github.io/av1-isobmff/#codecsparam
// FORMAT: [codecTag].[profile].[level][tier].[bitDepth]
StringBuilder result = new StringBuilder("av01", 13);

Expand All @@ -214,8 +214,7 @@ public static string GetAv1String(string? profile, int level, bool tierFlag, int
result.Append(".0");
}

if (level <= 0
|| level > 31)
if (level is <= 0 or > 31)
{
// Default to the maximum defined level 6.3
level = 19;
Expand All @@ -230,7 +229,8 @@ public static string GetAv1String(string? profile, int level, bool tierFlag, int
}

result.Append('.')
.Append(level)
// Needed to pad it double digits; otherwise, browsers will reject the stream.
.AppendFormat(CultureInfo.InvariantCulture, "{0:D2}", level)
.Append(tierFlag ? 'H' : 'M');

string bitDepthD2 = bitDepth.ToString("D2", CultureInfo.InvariantCulture);
Expand Down

0 comments on commit b57747b

Please sign in to comment.