Files
Chronos/tests/Chronos.Core.Tests/Video/CodecLimitsTests.cs
T
Alby96andClaude Opus 5.5 5f27a86406
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
refactor!: rename Titano to Chronos and move CI and releases to Gitea
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout. The release cross-compiles the Windows programs, checks their
  icon, version and DPI manifest, packs installers and zips, publishes the
  Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only
  tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow) and
  pe-check.

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 11:34:48 +02:00

71 lines
3.5 KiB
C#

using Chronos.Core.Video;
using Chronos.Testing;
namespace Chronos.Core.Tests.Video;
public sealed class CodecLimitsTests
{
[Theory]
[Case(VideoCodec.H264, 1920, 1080, 30.0, 6_220_800L, "4.0", Name = "1080p30 H.264 (0.10 bpp)")]
[Case(VideoCodec.H264, 1920, 1080, 60.0, 12_441_600L, "4.2")]
[Case(VideoCodec.H264, 1280, 720, 30.0, 0L, "3.1")]
[Case(VideoCodec.H264, 3840, 2160, 30.0, 24_883_200L, "5.1")]
[Case(VideoCodec.H264, 1920, 1080, 30.0, 40_000_000L, "4.1", Name = "1080p30 H.264 at 40 Mbit/s")]
[Case(VideoCodec.Hevc, 3840, 2160, 60.0, 34_836_480L, "5.1", Name = "4K60 HEVC (0.07 bpp)")]
[Case(VideoCodec.Hevc, 7680, 4320, 30.0, 69_672_960L, "6.1", Name = "8K30 HEVC (0.07 bpp)")]
[Case(VideoCodec.Hevc, 7680, 4320, 30.0, 50_000_000L, "6.0")]
[Case(VideoCodec.Hevc, 1920, 1080, 30.0, 0L, "4.0")]
[Case(VideoCodec.Av1, 1920, 1080, 30.0, 0L, "4.0")]
[Case(VideoCodec.Av1, 3840, 2160, 60.0, 29_859_840L, "5.1")]
[Case(VideoCodec.Av1, 640, 360, 24.0, 0L, "2.1")]
public void ChoosesLowestFittingLevel(VideoCodec codec, int width, int height, double fps, long bitRate, string level)
{
var check = CodecLimits.Check(codec, width, height, fps, bitRate);
Assert.True(check.Fits);
Assert.Equal(level, check.Level!.Value.Name);
Assert.Equal(LevelLimit.None, check.Exceeded);
Assert.Equal(width, check.SuggestedWidth);
}
[Test]
public void LevelIdentifiersMatchTheBitstreamCodes()
{
Assert.Equal(41, new CodecLevel(VideoCodec.H264, 4, 1).H264LevelIdc);
Assert.Equal(153, new CodecLevel(VideoCodec.Hevc, 5, 1).HevcLevelIdc);
Assert.Equal(186, new CodecLevel(VideoCodec.Hevc, 6, 2).HevcLevelIdc);
Assert.Equal(13, new CodecLevel(VideoCodec.Av1, 5, 1).Av1SeqLevelIdx);
Assert.Equal(19, CodecLimits.Levels(VideoCodec.H264).Count);
Assert.Equal("6.3", CodecLimits.Levels(VideoCodec.Av1)[^1].Name);
}
[Theory]
[Case(VideoCodec.H264, 16384, 8640, 30.0)]
[Case(VideoCodec.Hevc, 15360, 8640, 60.0)]
[Case(VideoCodec.Av1, 20000, 10000, 30.0)]
public void OversizedConfigurationsGetACappedSuggestion(VideoCodec codec, int width, int height, double fps)
{
var check = CodecLimits.Check(codec, width, height, fps, 0);
Assert.False(check.Fits);
Assert.True((check.Exceeded & (LevelLimit.PictureSize | LevelLimit.SampleRate | LevelLimit.Dimension)) != 0);
Assert.True(check.SuggestedWidth % 2 == 0 && check.SuggestedHeight % 2 == 0);
Assert.Approximately(width / (double)height, check.SuggestedWidth / (double)check.SuggestedHeight, 0.01);
Assert.True(CodecLimits.Check(codec, check.SuggestedWidth, check.SuggestedHeight, fps, 0).Fits);
// The suggestion is tight: a slightly larger size no longer fits.
var w = check.SuggestedWidth + 64;
var h = (int)Math.Round(w * (double)height / width);
Assert.False(CodecLimits.Check(codec, w, h, fps, 0).Fits);
}
[Test]
public void ExcessiveBitRateIsReportedWithoutResizing()
{
var check = CodecLimits.Check(VideoCodec.H264, 1920, 1080, 30, 2_000_000_000, CodecProfile.H264High);
Assert.False(check.Fits);
Assert.Equal(LevelLimit.BitRate, check.Exceeded);
Assert.Equal(1920, check.SuggestedWidth);
Assert.Equal(1080, check.SuggestedHeight);
Assert.Equal(1_000_000_000L, check.MaxBitRate);
Assert.Equal(800_000_000L, CodecLimits.Check(VideoCodec.H264, 64, 64, 30, 0, CodecProfile.H264Main).MaxBitRate);
}
}