Repository navigation
feat(h264): refine two trailing coefficients #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a701871
docs(h264): plan the stronger coefficient default
gunwooterry 43b0ffc
feat(h264): refine two trailing coefficients
gunwooterry d50b5eb
docs(h264): describe the two-coordinate default
gunwooterry 980d571
docs(h264): set total coefficient-cost limits
gunwooterry be33b6e
docs(h264): retain the stronger budget result
gunwooterry 6c1a249
test(h264): read measured text as UTF-8
gunwooterry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import math | ||
| from pathlib import Path | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| import unittest | ||
|
|
||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
|
|
||
|
|
||
| class CoefficientDesignTests(unittest.TestCase): | ||
| def assert_reference(self, text): | ||
| section = text.split('### Stronger default coefficient budget\n', 1)[1].split('\n### ', 1)[0] | ||
| source = (ROOT / 'crates/coreav-h264-encoder/src/levels.rs').read_text(encoding='utf-8') | ||
| budget = re.search(r'const AC_COORDINATES: usize = (\d+);', source).group(1) | ||
| self.assertIn(f'Measured ordinary-block budget: `{budget}`.', section, 'Record the measured tradeoff for the current coefficient budget') | ||
| self.assertRegex(section, r'Measured candidate: `[0-9a-f]{40}`; direct baseline: `[0-9a-f]{40}`', 'Bind the documented tradeoff to both complete source identities') | ||
| rows = [line.split('|')[1:-1] for line in section.splitlines() if re.match(r'^\| [A-E] \|', line)] | ||
| self.assertEqual([row[0].strip() for row in rows], list('ABCDE'), 'Record every input, not just the throughput limit') | ||
| for row in rows: | ||
| self.assertEqual(len(row), 6, 'Record Y/U/V and both one/four-worker throughputs') | ||
| for value, suffix in zip(row[1:], ('%', '%', '%', '×', '×')): | ||
| value = value.strip() | ||
| self.assertTrue(value.endswith(suffix)) | ||
| self.assertTrue(math.isfinite(float(value[:-1].replace('−', '-')))) | ||
| self.assertIn('shared-host reference', section, 'Keep the shared-host qualification with the result') | ||
|
|
||
| def test_current_budget_has_source_bound_measured_tradeoff(self): | ||
| self.assert_reference((ROOT / 'docs/design/h264-encoder-pipeline.md').read_text(encoding='utf-8')) | ||
|
|
||
| def test_missing_result_and_changed_budget_are_rejected(self): | ||
| text = (ROOT / 'docs/design/h264-encoder-pipeline.md').read_text(encoding='utf-8') | ||
| start = text.index('Measured ordinary-block budget:') | ||
| end = text.index('Count the ceiling before implementing', start) | ||
| missing = text[:start] + text[end:] | ||
| changed = re.sub(r'Measured ordinary-block budget: `(\d+)`\.', lambda match: f'Measured ordinary-block budget: `{int(match.group(1)) + 1}`.', text, count=1) | ||
| for invalid in (missing, changed): | ||
| with self.subTest(missing=invalid == missing), self.assertRaises(AssertionError): | ||
| self.assert_reference(invalid) | ||
|
|
||
| def test_document_reads_do_not_use_locale_defaults(self): | ||
| result = subprocess.run([ | ||
| sys.executable, '-X', 'warn_default_encoding', '-W', 'error::EncodingWarning', | ||
| str(Path(__file__).resolve()), | ||
| 'CoefficientDesignTests.test_current_budget_has_source_bound_measured_tradeoff', | ||
| 'CoefficientDesignTests.test_missing_result_and_changed_budget_are_rejected', | ||
| ], capture_output=True, timeout=30) | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.