Encoder testing

This commit is contained in:
2026-06-08 12:14:32 +02:00
parent 444d62edac
commit d6aa880104
6 changed files with 261 additions and 61 deletions
+15 -7
View File
@@ -31,6 +31,9 @@
(verify? . #f)
(blocksize . 0))))
(define (source-value v source)
(if (eq? v 'source) source v))
(define (safe-flac-bits bits)
(cond [(and (integer? bits) (or (= bits 8) (= bits 12) (= bits 16) (= bits 20) (= bits 24))) bits]
[(and (integer? bits) (< bits 16)) 16]
@@ -41,13 +44,18 @@
(h (hash-merge base settings))
;; In encoder settings, 'sample-rate means the requested output rate.
;; 'target-sample-rate is accepted as an explicit alias for readability.
(rate (hash-ref/default h 'target-sample-rate
(hash-ref/default h 'sample-rate (hash-ref format 'sample-rate))))
(channels (hash-ref/default h 'target-channels
(hash-ref/default h 'channels (hash-ref format 'channels))))
(bits0 (hash-ref/default h 'target-bits-per-sample
(hash-ref/default h 'bits-per-sample
(hash-ref/default format 'bits-per-sample 24))))
(source-rate (hash-ref format 'sample-rate))
(source-channels (hash-ref format 'channels))
(source-bits (hash-ref/default format 'bits-per-sample 24))
(rate (source-value (hash-ref/default h 'target-sample-rate
(hash-ref/default h 'sample-rate source-rate))
source-rate))
(channels (source-value (hash-ref/default h 'target-channels
(hash-ref/default h 'channels source-channels))
source-channels))
(bits0 (source-value (hash-ref/default h 'target-bits-per-sample
(hash-ref/default h 'bits-per-sample source-bits))
source-bits))
(bits (safe-flac-bits bits0))
(total (hash-ref/default h 'total-samples (hash-ref/default format 'total-samples #f))))
(hash-set! h 'sample-rate rate)