forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

hevc10-hdr-check.sh43 lines, 2.3 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# hevc10-hdr-check.sh: ffprobe/ffmpeg check of ec-h265 Main 10 HDR output. Encodes a
3# synthetic 10-bit clip (testsrc2, mandelbrot, gradients) as intra and GOP with PQ and
4# HLG tags, then asserts ffprobe reports profile=Main 10, pix_fmt=yuv420p10le and the
5# colour tags, and that ffmpeg's decode equals the encoder reconstruction byte for byte.
6# Usage (on a host with ffmpeg and cargo): scripts/hevc10-hdr-check.sh
7set -euo pipefail
8here=$(cd "$(dirname "$0")/.." && pwd)
9data=${DATA:-$HOME/.cache/hevc10-hdr-data}
10mkdir -p "$data"
11cargo build --release -q -p ec-h265 --example hevc_gop --manifest-path "$here/Cargo.toml"
12target=$(cargo metadata --format-version 1 --no-deps --manifest-path "$here/Cargo.toml" \
13 | python3 -I -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])')
14bin="$target/release/examples/hevc_gop"
15export EC_H265_BITDEPTH=10
16fail=0
17for src in testsrc2 mandelbrot gradients; do
18 case $src in
19 gradients) lavfi="gradients=s=416x240:r=30" ;;
20 *) lavfi="$src=s=416x240:r=30" ;;
21 esac
22 yuv="$data/$src.yuv"
23 ffmpeg -v error -y -f lavfi -i "$lavfi" -t 2 -pix_fmt yuv420p10le -f rawvideo "$yuv"
24 for mode in pq hlg; do
25 for gop in 1 8; do
26 bs="$data/$src-$mode-$gop.h265"; rec="$data/$src-$mode-$gop.rec"; dec="$data/$src-$mode-$gop.dec"
27 EC_H265_HDR=$mode EC_H265_FULL_RANGE=$([ $mode = hlg ] && echo 1 || echo 0) \
28 "$bin" encode "$yuv" 416 240 "$gop" 24 "$bs" "$rec" >/dev/null
29 info=$(ffprobe -v error -select_streams v:0 -show_entries \
30 stream=profile,pix_fmt,color_primaries,color_transfer,color_space,color_range,chroma_location \
31 -of default=nw=1 "$bs" | tr '\n' ' ')
32 want_tr=$([ $mode = hlg ] && echo arib-std-b67 || echo smpte2084)
33 want_rg=$([ $mode = hlg ] && echo pc || echo tv)
34 for k in "profile=Main 10" "pix_fmt=yuv420p10le" "color_primaries=bt2020" \
35 "color_transfer=$want_tr" "color_space=bt2020nc" "color_range=$want_rg"; do
36 case "$info" in *"$k"*) ;; *) echo "FAIL $src $mode gop$gop: missing '$k' in: $info"; fail=1 ;; esac
37 done
38 ffmpeg -v error -y -i "$bs" -pix_fmt yuv420p10le -f rawvideo "$dec"
39 if cmp -s "$rec" "$dec"; then echo "ok $src $mode gop$gop: $info"; else echo "FAIL $src $mode gop$gop: ffmpeg != recon"; fail=1; fi
40 done
41 done
42done
43exit $fail