edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB5a2f5efTahinli3 months ago1409 commits
| 1 | #!/usr/bin/env bash |
| 2 | # gen-fixtures.sh — deterministic ffmpeg-generated media fixtures for edith_codecs. |
| 3 | # |
| 4 | # ffmpeg is ORACLE/test-input tooling only; no ec-* crate depends on it at runtime. |
| 5 | # Idempotent: non-empty outputs are skipped, partial outputs are deleted on failure. |
| 6 | # Content is deterministic (sine tones per channel, testsrc2) so regenerating on |
| 7 | # another machine with the same ffmpeg yields the same bytes. |
| 8 | # |
| 9 | # Usage: scripts/gen-fixtures.sh [-f] (-f: regenerate everything) |
| 10 | # Env: EC_FIXTURES=<dir> (default <repo>/fixtures) |
| 11 | |
| 12 | |
| 13 | |
| 14 | ROOT= |
| 15 | FIXTURES= |
| 16 | DUR_A=3 |
| 17 | DUR_V=2 |
| 18 | FORCE=0 |
| 19 | [ && FORCE=1 |
| 20 | |
| 21 | || { ; ; } |
| 22 | |
| 23 | TMPLOG= || |
| 24 | |
| 25 | |
| 26 | n_made=0 |
| 27 | n_skip=0 |
| 28 | failed=() |
| 29 | unsupported=() |
| 30 | |
| 31 | # gen <out> <ffmpeg args...> |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | # ---------------------------------------------------------------- audio ----- |
| 51 | # Per-channel distinct frequencies: lets the oracle catch channel-order bugs |
| 52 | # (5.1 order FL,FR,FC,LFE,BL,BR) that identical-tone fixtures hide. |
| 53 | FREQS=(220 440 660 55 880 1320) |
| 54 | |
| 55 | # build_audio_in <nch> <rate> -> sets AIN[] and AMAP[] |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | # name|ext|encoder args |
| 76 | AUDIO_CODECS=( |
| 77 | "wav16|wav|-c:a pcm_s16le" |
| 78 | "flac|flac|-c:a flac -compression_level 5" |
| 79 | "mp3|mp3|-c:a libmp3lame -b:a 192k" |
| 80 | "aac-adts|aac|-c:a aac -b:a 160k" |
| 81 | "aac-mp4|mp4|-c:a aac -b:a 160k" |
| 82 | "ac3|ac3|-c:a ac3 -b:a 448k" |
| 83 | "eac3|eac3|-c:a eac3 -b:a 448k" |
| 84 | "vorbis-ogg|ogg|-c:a libvorbis -q:a 5" |
| 85 | "opus-ogg|opus|-c:a libopus -b:a 160k -vbr on" |
| 86 | "alac-mp4|m4a|-c:a alac" |
| 87 | ) |
| 88 | LAYOUTS=("mono|1" "stereo|2" "5.1|6") |
| 89 | RATES=(44100 48000) |
| 90 | |
| 91 | for; do |
| 92 | IFS='|' |
| 93 | |
| 94 | for; do |
| 95 | IFS='|' |
| 96 | for; do |
| 97 | # Encoder capability gates — a skipped combo is reported, never silent. |
| 98 | if [ && [; then |
| 99 | unsupported+=("audio/--: libmp3lame is mono/stereo only") |
| 100 | continue |
| 101 | fi |
| 102 | if [ && [; then |
| 103 | unsupported+=("audio/--: libopus encodes at 48 kHz only") |
| 104 | continue |
| 105 | fi |
| 106 | |
| 107 | |
| 108 | |
| 109 | done |
| 110 | done |
| 111 | done |
| 112 | |
| 113 | # ------------------------------------------------- probe/ALAC extras -------- |
| 114 | # 24-bit ALAC: the only path where the low bytes of a sample ride uncompressed |
| 115 | # beside the residuals, which 16-bit fixtures never exercise. |
| 116 | for; do |
| 117 | IFS='|' |
| 118 | |
| 119 | |
| 120 | |
| 121 | done |
| 122 | |
| 123 | # AAC coding-tool isolation: one fixture per §4.6 tool ffmpeg's native aac |
| 124 | # encoder can force on its own (plus one with all four), so a decode |
| 125 | # regression in any single tool pins to its own fixture rather than a mix. |
| 126 | AAC_TOOL_VARIANTS=( |
| 127 | "pns|-aac_pns 1 -aac_is 0 -aac_ms 0 -aac_tns 0" |
| 128 | "is|-aac_pns 0 -aac_is 1 -aac_ms 0 -aac_tns 0" |
| 129 | "ms|-aac_pns 0 -aac_is 0 -aac_ms 1 -aac_tns 0" |
| 130 | "tns|-aac_pns 0 -aac_is 0 -aac_ms 0 -aac_tns 1" |
| 131 | "all|-aac_pns 1 -aac_is 1 -aac_ms 1 -aac_tns 1" |
| 132 | ) |
| 133 | for; do |
| 134 | IFS='|' |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | done |
| 140 | |
| 141 | # Matroska-carried audio: what the probe hands to the Matroska reader rather |
| 142 | # than parsing itself. One per codec family that has a Matroska mapping. |
| 143 | for; do |
| 144 | IFS='|' |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | done |
| 150 | # A film-shaped Matroska: picture and sound in one file, which is how a probe |
| 151 | # meets one in the real library. |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | # Cover art: an mjpeg "video" stream that is a still picture, in the two |
| 158 | # containers that carry one. A probe that lists it as a video track is broken. |
| 159 | if [ && [; then |
| 160 | |
| 161 | fi |
| 162 | if [; then |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | fi |
| 176 | |
| 177 | # ---------------------------------------------------------------- video ----- |
| 178 | # name|encoder|extra args|pix_fmts (comma-separated) |
| 179 | VIDEO_CODECS=( |
| 180 | "h264|libx264|-preset ultrafast -crf 23|yuv420p" |
| 181 | "hevc|libx265|-preset ultrafast -crf 28 -x265-params log-level=error|yuv420p,yuv420p10le" |
| 182 | "vp9|libvpx-vp9|-deadline realtime -cpu-used 8 -row-mt 1 -b:v 0 -crf 32|yuv420p,yuv420p10le" |
| 183 | "av1|librav1e|-speed 10 -qp 100|yuv420p,yuv420p10le" |
| 184 | ) |
| 185 | FPS=("23.976|24000/1001" "60|60") |
| 186 | CONTAINERS=(mp4 mkv) |
| 187 | |
| 188 | # gen_video <codec> <encoder> <extra-args-str> <pix_fmt> <fpstag> <fpsval> <WxH> <restag> <container> |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | for; do |
| 202 | IFS='|' |
| 203 | IFS=',' |
| 204 | for; do |
| 205 | for; do |
| 206 | IFS='|' |
| 207 | for; do |
| 208 | |
| 209 | done |
| 210 | done |
| 211 | done |
| 212 | # One 4K sample per codec (8-bit, mp4, 23.976) — size/stride edge cases. |
| 213 | |
| 214 | # 1916x1080: not a multiple of the macroblock/CTU size, so the decoder must |
| 215 | # honour the cropping rect / conformance window. The real library has BluRay |
| 216 | # remuxes at exactly this size, and every other fixture here is CTU-aligned. |
| 217 | case in |
| 218 | h264 | hevc) ;; |
| 219 | esac |
| 220 | done |
| 221 | |
| 222 | # Open-GOP H.264: a non-IDR I picture (nal_unit_type 1, not 5) at a GOP |
| 223 | # boundary, with B-pyramid pictures around it referencing across the |
| 224 | # boundary. A decoder started fresh at that I (what a seek does) must not |
| 225 | # hand back a picture whose references it never decoded — the H.264 sibling |
| 226 | # of the HEVC RASL/NoRaslOutputFlag case. |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | # -------------------------------------------------------------- summary ----- |
| 232 | |
| 233 | |
| 234 | total=0 |
| 235 | while ; do |
| 236 | total= |
| 237 | sz= |
| 238 | p= |
| 239 | |
| 240 | |
| 241 | done |
| 242 | |
| 243 | |
| 244 | for; do [ && ; done |
| 245 | for; do [ && ; done |
| 246 | [ || |