Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions .github/workflows/hevc-reference.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hevc-reference
run-name: HEVC reference ${{ inputs.candidate }}
run-name: HEVC reference ${{ inputs.candidate }} (${{ inputs.only || 'all' }}, cap ${{ inputs.frames }})
# workflow-check: not required

on:
Expand All @@ -9,11 +9,26 @@ on:
description: Exact decoder commit
required: true
type: string
baseline:
description: Optional full main SHA for the threading comparison
required: false
default: ''
type: string
sanitizer_only:
description: Run only the threading sanitizer stress check
required: false
default: false
type: boolean
only:
description: Optional comma-separated input IDs
required: false
default: ''
type: string
frames:
description: Maximum pictures per reference input
required: false
default: 32
type: number
diagnose_only:
description: Compare pixels without timing or profiling
required: false
Expand All @@ -25,12 +40,14 @@ permissions:

jobs:
reference:
if: inputs.baseline == '' && !inputs.sanitizer_only
runs-on: ubuntu-24.04
timeout-minutes: 150
env:
CANDIDATE: ${{ inputs.candidate }}
ONLY: ${{ inputs.only }}
DIAGNOSE_ONLY: ${{ inputs.diagnose_only }}
FRAMES: ${{ inputs.frames }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
Expand Down Expand Up @@ -81,7 +98,7 @@ jobs:
python3 -I driver/scripts/hevc_reference.py \
--native "$PWD/candidate/target/release/examples/reference" \
--oracle-bin "$RUNNER_TEMP/oracle" --out "$RUNNER_TEMP/reference" \
--candidate "$CANDIDATE" --only "$ONLY" "${EXTRA[@]}"
--candidate "$CANDIDATE" --only "$ONLY" --frames "$FRAMES" "${EXTRA[@]}"
- name: Bind retained results to the dispatched decoder
run: |
python3 -I driver/scripts/hevc_reference.py check-result \
Expand All @@ -95,3 +112,14 @@ jobs:
${{ runner.temp }}/compiler.txt
if-no-files-found: error
retention-days: 30

threading:
if: inputs.baseline != '' || inputs.sanitizer_only
uses: ./.github/workflows/hevc-threading.yml
with:
candidate: ${{ inputs.candidate }}
baseline: ${{ inputs.baseline }}
sanitizer_only: ${{ inputs.sanitizer_only }}
only: ${{ inputs.only }}
frames: ${{ fromJSON(inputs.frames) }}
secrets: inherit
197 changes: 197 additions & 0 deletions .github/workflows/hevc-threading.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: hevc-threading
# workflow-check: not required

on:
workflow_call:
inputs:
candidate:
required: true
type: string
baseline:
required: true
type: string
sanitizer_only:
required: false
default: false
type: boolean
only:
required: false
default: ''
type: string
frames:
required: false
default: 32
type: number

permissions:
contents: read

env:
CANDIDATE: ${{ inputs.candidate }}
BASELINE: ${{ inputs.baseline }}
ONLY: ${{ inputs.only }}
FRAMES: ${{ inputs.frames }}

jobs:
reference:
if: '!inputs.sanitizer_only'
name: hevc-threading-reference (${{ matrix.shard }})
runs-on: ubuntu-24.04
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
shard: ${{ fromJSON(inputs.only != '' && '[0]' || '[0,1,2]') }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
ref: ${{ inputs.candidate }}
fetch-depth: 0
path: candidate
- name: Admit exact branch arms before building or using credentials
working-directory: candidate
run: |
set -euo pipefail
[[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ && "$BASELINE" =~ ^[0-9a-f]{40}$ ]]
test "$(git rev-parse HEAD)" = "$CANDIDATE"
test -n "$(git branch -r --contains "$CANDIDATE")"
git merge-base --is-ancestor "$BASELINE" origin/main
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
ref: ${{ inputs.baseline }}
path: baseline
- uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249
with:
toolchain: stable
- name: Build distinct candidate and serial-main executables
run: |
set -euo pipefail
cp candidate/bench/hevc-reference/decode.rs candidate/crates/coreav-hevc/examples/reference.rs
cp candidate/bench/hevc-reference/decode.rs baseline/crates/coreav-hevc/examples/reference.rs
(cd candidate && RUSTFLAGS='--check-cfg=cfg(hevc_serial_baseline)' cargo build --locked --release -p coreav-hevc --features native-hevc --example reference --example headers)
(cd baseline && test "$(git rev-parse HEAD)" = "$BASELINE" && RUSTFLAGS='--cfg hevc_serial_baseline --check-cfg=cfg(hevc_serial_baseline)' cargo build --locked --release -p coreav-hevc --features native-hevc --example reference)
- name: Install the pinned binary oracle
env:
R2_ENDPOINT: ${{ secrets.COREAV_CORPUS_R2_ENDPOINT }}
R2_ACCESS_KEY_ID: ${{ secrets.COREAV_CORPUS_R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.COREAV_CORPUS_R2_SECRET_ACCESS_KEY }}
R2_BUCKET: ${{ vars.COREAV_CORPUS_R2_BUCKET }}
run: candidate/scripts/install-oracle-ffmpeg.sh "$RUNNER_TEMP/oracle"
- name: Verify every thread count before paired reference calls
env:
R2_ENDPOINT: ${{ secrets.COREAV_CORPUS_R2_ENDPOINT }}
R2_ACCESS_KEY_ID: ${{ secrets.COREAV_CORPUS_R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.COREAV_CORPUS_R2_SECRET_ACCESS_KEY }}
R2_BUCKET: ${{ vars.COREAV_CORPUS_R2_BUCKET }}
run: |
umask 077
mkdir -p "$RUNNER_TEMP/private"
python3 -I candidate/scripts/hevc_threading.py \
--native "$PWD/candidate/target/release/examples/reference" \
--main "$PWD/baseline/target/release/examples/reference" \
--oracle-bin "$RUNNER_TEMP/oracle" --out "$RUNNER_TEMP/private" \
--candidate "$CANDIDATE" --baseline "$BASELINE" \
--shard-index '${{ matrix.shard }}' --shard-count '${{ inputs.only != '' && 1 || 3 }}' --only "$ONLY" --frames "$FRAMES"
- name: Seal reference results
if: always()
run: |
set -euo pipefail
cd "$RUNNER_TEMP"
[ -d private ] || exit 0
tar -czf records.tgz private
mkdir -p sealed
openssl rand -hex -out key.txt 32
openssl enc -aes-256-cbc -pbkdf2 -salt -pass file:key.txt -in records.tgz -out sealed/records.tgz.enc
openssl pkeyutl -encrypt -pubin -inkey "$GITHUB_WORKSPACE/candidate/bench/hevc-conformance/evidence-public.pem" -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -in key.txt -out sealed/key.txt.enc
shred -u key.txt records.tgz
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
if: always()
with:
name: hevc-threading-reference-${{ matrix.shard }}-${{ inputs.candidate }}
path: ${{ runner.temp }}/sealed
if-no-files-found: error
retention-days: 7

conformance:
if: ${{ !inputs.sanitizer_only && inputs.only == '' }}
name: hevc-threading-conformance
runs-on: ubuntu-24.04
timeout-minutes: 360
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
ref: ${{ inputs.candidate }}
fetch-depth: 0
- name: Admit the exact candidate
run: |
set -euo pipefail
[[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ ]]
test "$(git rev-parse HEAD)" = "$CANDIDATE"
test -n "$(git branch -r --contains "$CANDIDATE")"
- uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249
with:
toolchain: stable
- run: cargo build --locked --release -p coreav-hevc --features native-hevc --example headers --example decode
- run: scripts/install-oracle-ffmpeg.sh "$RUNNER_TEMP/oracle"
- name: Prepare complete conformance references
run: |
set -euo pipefail
umask 077
mkdir -p "$RUNNER_TEMP/private"
python3 -I scripts/hevc_fixture.py verify --ffmpeg "$RUNNER_TEMP/oracle/ffmpeg" --ffprobe "$RUNNER_TEMP/oracle/ffprobe" --output "$RUNNER_TEMP/synthetic" > "$RUNNER_TEMP/private/synthetic.log" 2>&1
python3 -I scripts/hevc_conformance.py acquire --dest "$RUNNER_TEMP/data" > "$RUNNER_TEMP/private/acquire.log" 2>&1
python3 -I scripts/hevc_conformance.py manifest --data "$RUNNER_TEMP/data" --out "$RUNNER_TEMP/private/archives.json" > "$RUNNER_TEMP/private/manifest.log" 2>&1
python3 -I scripts/hevc_conformance.py run --registration "$RUNNER_TEMP/private/archives.json" --data "$RUNNER_TEMP/data" --out "$RUNNER_TEMP/private/census" --parser "$PWD/target/release/examples/headers" --oracle-bin "$RUNNER_TEMP/oracle" --synthetic-data "$RUNNER_TEMP/synthetic" > "$RUNNER_TEMP/private/census.log" 2>&1
- name: Compare complete outputs at one two four and eight threads
run: |
set -euo pipefail
for threads in 1 2 4 8; do
python3 -I scripts/hevc_decode.py --registration "$RUNNER_TEMP/private/archives.json" --census "$RUNNER_TEMP/private/census/census.json" --data "$RUNNER_TEMP/data" --out "$RUNNER_TEMP/private/threads-$threads" --parser "$PWD/target/release/examples/headers" --native "$PWD/target/release/examples/decode" --oracle-bin "$RUNNER_TEMP/oracle" --threads "$threads" > "$RUNNER_TEMP/private/threads-$threads.log" 2>&1
done
- name: Seal conformance records
if: always()
run: |
set -euo pipefail
cd "$RUNNER_TEMP"
[ -d private ] || exit 0
tar -czf records.tgz private
mkdir -p sealed
openssl rand -hex -out key.txt 32
openssl enc -aes-256-cbc -pbkdf2 -salt -pass file:key.txt -in records.tgz -out sealed/records.tgz.enc
openssl pkeyutl -encrypt -pubin -inkey "$GITHUB_WORKSPACE/bench/hevc-conformance/evidence-public.pem" -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -in key.txt -out sealed/key.txt.enc
shred -u key.txt records.tgz
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
if: always()
with:
name: hevc-threading-conformance-${{ inputs.candidate }}
path: ${{ runner.temp }}/sealed
if-no-files-found: error
retention-days: 7

thread-sanitizer:
if: ${{ inputs.sanitizer_only || inputs.only == '' }}
name: hevc-threading-sanitizer
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
ref: ${{ inputs.candidate }}
- uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249
with:
toolchain: nightly
components: rust-src
- name: Stress wavefront completion and failure under ThreadSanitizer
env:
RUSTFLAGS: -Zsanitizer=thread
RUSTDOCFLAGS: -Zsanitizer=thread
run: |
set -euo pipefail
sudo sysctl vm.mmap_rnd_bits=28
for repeat in $(seq 1 20); do
cargo +nightly test --locked -Zbuild-std --target x86_64-unknown-linux-gnu -p coreav-hevc --features native-hevc --lib wavefront
done
2 changes: 1 addition & 1 deletion bench/hevc-conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ python3 -I scripts/hevc_decode.py \
--max-picture-bins 268435456
```

The comparator consumes the complete source-bound census, preserves every archive disposition and requires the published whole-output anchor before comparing individual output pictures. It checks original coded/output identities, geometry, packing, hashes, effective work and budget controls. `--select-test` is diagnostic only and cannot report complete coverage. The `decode` example accepts `INPUT MAX_MEMORY_BYTES MAX_STREAM_BINS MAX_PICTURE_BINS`; `-` reads standard input. Its bounded JSON lines contain each output picture and a final successful-completion summary. Annex B timestamps remain null. This command and its fixture tests are implemented. Original-media C1 and C2 comparisons run in the full tier, not the routine smoke.
The comparator consumes the complete source-bound census, preserves every archive disposition and requires the published whole-output anchor before comparing individual output pictures. It checks original coded/output identities, geometry, packing, hashes, effective work and budget controls. `--select-test` is diagnostic only and cannot report complete coverage. The `decode` example accepts `INPUT MAX_MEMORY_BYTES MAX_STREAM_BINS MAX_PICTURE_BINS [THREADS]`; `-` reads standard input. The optional `hevc_decode.py --threads N` supplies that last argument to both valid-stream comparisons and failure controls. Without it, decoding uses one worker. Its bounded JSON lines contain each output picture and a final successful-completion summary, including the actual maximum worker count and parallel-picture count. Annex B timestamps remain null. This command and its fixture tests are implemented. Original-media C1 and C2 comparisons run in the full tier, not the routine smoke.

### Container packet comparison

Expand Down
44 changes: 37 additions & 7 deletions bench/hevc-reference/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ fn run(writer: &mut impl Write) -> Result<()> {
let mode = args
.next()
.ok_or(Error::InvalidData("reference_arguments"))?;
let threads = args
.next()
.map(|value| {
value
.into_string()
.ok()
.and_then(|value| value.parse::<usize>().ok())
})
.unwrap_or(Some(1))
.filter(|value| *value <= 16)
.ok_or(Error::InvalidData("reference_arguments"))?;
let threads = if threads == 0 {
std::thread::available_parallelism()
.map_or(1, usize::from)
.min(16)
} else {
threads
};
if args.next().is_some() || (mode != "check" && mode != "decode") {
return Err(Error::InvalidData("reference_arguments"));
}
Expand All @@ -29,10 +47,19 @@ fn run(writer: &mut impl Write) -> Result<()> {
return Err(Error::Limit("reference_input"));
}
let limits = DecodeLimits {
max_memory_bytes: 1 << 30,
max_memory_bytes: usize::try_from(coreav_decode::Limits::default().max_memory_bytes)
.map_err(|_| Error::Limit("reference_memory"))?,
..DecodeLimits::default()
};
let mut decoder = PictureDecoder::new(limits);
#[cfg(not(hevc_serial_baseline))]
{
decoder = decoder.with_threads(threads);
}
#[cfg(hevc_serial_baseline)]
{
std::hint::black_box(threads);
}
let mut output = decoded::Output::new(writer);
let mut pictures = 0u64;
let mut callback = |picture: coreav_hevc::DecodedPicture<'_>| {
Expand All @@ -51,12 +78,15 @@ fn run(writer: &mut impl Write) -> Result<()> {
if mode == "check" {
output.finish(summary, receipt, limits)
} else {
serde_json::to_writer(
&mut *writer,
&json!({"pictures":pictures,
"decoded_pictures":summary.decoded_pictures,"bins":summary.reconstruction.bins}),
)
.map_err(|_| Error::Limit("reference_output"))?;
let mut record = json!({"pictures":pictures,"thread_limit":threads,"max_memory_bytes":limits.max_memory_bytes,
"decoded_pictures":summary.decoded_pictures,"bins":summary.reconstruction.bins});
#[cfg(not(hevc_serial_baseline))]
{
record["parallel_pictures"] = json!(summary.parallel_pictures);
record["max_workers"] = json!(summary.max_workers);
}
serde_json::to_writer(&mut *writer, &record)
.map_err(|_| Error::Limit("reference_output"))?;
writer
.write_all(b"\n")
.map_err(|_| Error::Limit("reference_output"))
Expand Down
4 changes: 4 additions & 0 deletions crates/coreav-backend-apple/src/hevc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use coreav_hevc::{HeaderParser, LengthPrefixed, NalHeader, NalInfo};
/// A refusal of the checked HEVC output contract.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Error {
/// An internal decoder or validator failure, not invalid output metadata.
Internal,
/// Truncated or invalid syntax or framing.
Malformed,
/// A profile, coding tool, or NAL type outside the output contract.
Expand All @@ -32,6 +34,7 @@ pub enum Error {
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Self::Internal => "internal HEVC failure",
Self::Malformed => "malformed HEVC output metadata",
Self::Unsupported => "unsupported HEVC output metadata",
Self::FormatMismatch => "HEVC output format changed",
Expand All @@ -50,6 +53,7 @@ impl std::error::Error for Error {}
impl From<coreav_hevc::Error> for Error {
fn from(error: coreav_hevc::Error) -> Self {
match error {
coreav_hevc::Error::Internal(_) => Self::Internal,
coreav_hevc::Error::InvalidData(_) => Self::Malformed,
coreav_hevc::Error::Unsupported(_) => Self::Unsupported,
coreav_hevc::Error::Limit(_) => Self::Limit,
Expand Down
8 changes: 8 additions & 0 deletions crates/coreav-backend-apple/tests/hevc_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ use coreav_backend_apple::{
hevc::{AccessUnit, Config, Error, Stream},
};

#[test]
fn decoder_internal_failure_is_not_a_metadata_or_resource_refusal() {
assert_eq!(
Error::from(coreav_hevc::Error::Internal("reconstruction_panic")),
Error::Internal
);
}

#[derive(Default)]
struct Writer(Vec<bool>);

Expand Down
Loading
Loading