[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/emms 6c3f1d6ab2 25/42: Use bindat-type in emms-info-opu
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/emms 6c3f1d6ab2 25/42: Use bindat-type in emms-info-opus |
|
Date: |
Wed, 1 Nov 2023 15:58:01 -0400 (EDT) |
branch: externals/emms
commit 6c3f1d6ab2b106a2fd732597e0e8d26c38252f76
Author: Petteri Hintsanen <petterih@iki.fi>
Commit: Petteri Hintsanen <petterih@iki.fi>
Use bindat-type in emms-info-opus
---
emms-info-opus.el | 151 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 98 insertions(+), 53 deletions(-)
diff --git a/emms-info-opus.el b/emms-info-opus.el
index 27012b6b9b..665e5e13a5 100644
--- a/emms-info-opus.el
+++ b/emms-info-opus.el
@@ -25,73 +25,118 @@
;; This file contains Opus-specific code for `emms-info-ogg' feature.
+(require 'emms)
(require 'emms-info-vorbis)
+(require 'bindat)
(defvar emms-info-opus--channel-count 0
- "Last decoded Opus channel count.
-This is a kludge; it is needed because bindat spec cannot refer
-outside itself.")
+ "Last decoded Opus channel count.")
-(defconst emms-info-opus--headers-bindat-spec
- '((identification-header struct emms-info-opus--id-header-bindat-spec)
- (comment-header struct emms-info-opus--comment-header-bindat-spec))
- "Specification for two first Opus header packets.
-They are always an identification header followed by a comment
-header.")
-
-(defconst emms-info-opus--id-header-bindat-spec
- '((opus-head vec 8)
- (eval (unless (equal last emms-info-opus--id-magic-pattern)
- (error "Opus framing mismatch: expected `%s', got `%s'"
- emms-info-opus--id-magic-pattern
- last)))
- (opus-version u8)
- (eval (unless (< last 16)
- (error "Opus version mismatch: expected < 16, got %s"
- last)))
- (channel-count u8)
- (eval (setq emms-info-opus--channel-count last))
- (pre-skip u16r)
- (sample-rate u32r)
- (output-gain u16r)
- (channel-mapping-family u8)
- (union (channel-mapping-family)
- (0 nil)
- (t (struct emms-info-opus--channel-mapping-bindat-spec))))
- "Opus identification header specification.")
-
-(defconst emms-info-opus--id-magic-pattern
- (string-to-vector "OpusHead")
+(defconst emms-info-opus--id-magic-pattern "OpusHead"
"Opus identification header magic pattern.")
(defconst emms-info-opus--channel-mapping-bindat-spec
+ (if emms--use-bindat-type
+ (bindat-type
+ (stream-count u8)
+ (coupled-count u8)
+ (channel-mapping vec emms-info-opus--channel-count))
'((stream-count u8)
(coupled-count u8)
- (channel-mapping vec (eval emms-info-opus--channel-count)))
+ (channel-mapping vec (eval emms-info-opus--channel-count))))
"Opus channel mapping table specification.")
+(defconst emms-info-opus--id-header-bindat-spec
+ (if emms--use-bindat-type
+ (bindat-type
+ (opus-head str 8)
+ (_ unit (unless (equal opus-head emms-info-opus--id-magic-pattern)
+ (error "Opus framing mismatch: expected `%s', got `%s'"
+ emms-info-opus--id-magic-pattern
+ opus-head)))
+ (opus-version u8)
+ (_ unit (unless (< opus-version 16)
+ (error "Opus version mismatch: expected < 16, got %s"
+ opus-version)))
+ (channel-count u8)
+ (pre-skip uint 16 'le)
+ (sample-rate uint 32 'le)
+ (output-gain uint 16 'le)
+ (channel-mapping-family u8)
+ (channel-mapping . (if (> channel-mapping-family 0)
+ (type
emms-info-opus--channel-mapping-bindat-spec)
+ (unit nil))))
+ '((opus-head str 8)
+ (eval (unless (equal last emms-info-opus--id-magic-pattern)
+ (error "Opus framing mismatch: expected `%s', got `%s'"
+ emms-info-opus--id-magic-pattern
+ last)))
+ (opus-version u8)
+ (eval (unless (< last 16)
+ (error "Opus version mismatch: expected < 16, got %s"
+ last)))
+ (channel-count u8)
+ (eval (setq emms-info-opus--channel-count last))
+ (pre-skip u16r)
+ (sample-rate u32r)
+ (output-gain u16r)
+ (channel-mapping-family u8)
+ (union (channel-mapping-family)
+ (0 nil)
+ (t (struct emms-info-opus--channel-mapping-bindat-spec)))))
+ "Opus identification header specification.")
+
+(defconst emms-info-opus--tags-magic-pattern "OpusTags"
+ "Opus comment header magic pattern.")
+
(defconst emms-info-opus--comment-header-bindat-spec
- '((opus-tags vec 8)
- (eval (unless (equal last emms-info-opus--tags-magic-pattern)
- (error "Opus framing mismatch: expected `%s', got `%s'"
- emms-info-opus--tags-magic-pattern
- last)))
- (vendor-length u32r)
- (eval (when (> last emms-info-vorbis--max-vendor-length)
- (error "Opus vendor length %s is too long" last)))
- (vendor-string vec (vendor-length))
- (user-comments-list-length u32r)
- (eval (when (> last emms-info-vorbis--max-comments)
- (error "Opus user comment list length %s is too long"
- last)))
- (user-comments repeat
- (user-comments-list-length)
- (struct emms-info-vorbis--comment-field-bindat-spec)))
+ (if emms--use-bindat-type
+ (bindat-type
+ (opus-tags str 8)
+ (_ unit (unless (equal opus-tags emms-info-opus--tags-magic-pattern)
+ (error "Opus framing mismatch: expected `%s', got `%s'"
+ emms-info-opus--tags-magic-pattern
+ opus-tags)))
+ (vendor-length uint 32 'le)
+ (_ unit (when (> vendor-length emms-info-vorbis--max-vendor-length)
+ (error "Opus vendor length %s is too long"
+ vendor-length)))
+ (vendor-string str vendor-length)
+ (user-comments-list-length uint 32 'le)
+ (_ unit (when (> user-comments-list-length
+ emms-info-vorbis--max-comments)
+ (error "Opus user comment list length %s is too long"
+ user-comments-list-length)))
+ (user-comments repeat user-comments-list-length
+ type emms-info-vorbis--comment-field-bindat-spec))
+ '((opus-tags str 8)
+ (eval (unless (equal last emms-info-opus--tags-magic-pattern)
+ (error "Opus framing mismatch: expected `%s', got `%s'"
+ emms-info-opus--tags-magic-pattern
+ last)))
+ (vendor-length u32r)
+ (eval (when (> last emms-info-vorbis--max-vendor-length)
+ (error "Opus vendor length %s is too long" last)))
+ (vendor-string str (vendor-length))
+ (user-comments-list-length u32r)
+ (eval (when (> last emms-info-vorbis--max-comments)
+ (error "Opus user comment list length %s is too long"
+ last)))
+ (user-comments repeat
+ (user-comments-list-length)
+ (struct emms-info-vorbis--comment-field-bindat-spec))))
"Opus comment header specification.")
-(defconst emms-info-opus--tags-magic-pattern
- (string-to-vector "OpusTags")
- "Opus comment header magic pattern.")
+(defconst emms-info-opus--headers-bindat-spec
+ (if emms--use-bindat-type
+ (bindat-type
+ (identification-header type emms-info-opus--id-header-bindat-spec)
+ (comment-header type emms-info-opus--comment-header-bindat-spec))
+ '((identification-header struct emms-info-opus--id-header-bindat-spec)
+ (comment-header struct emms-info-opus--comment-header-bindat-spec)))
+ "Specification for two first Opus header packets.
+They are always an identification header followed by a comment
+header.")
(provide 'emms-info-opus)
- [elpa] externals/emms c9dce6b305 36/42: Fix tests, (continued)
- [elpa] externals/emms c9dce6b305 36/42: Fix tests, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 93c614dc24 32/42: Fix byte compilation errors, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 83490a7218 38/42: Change all tests to use emms-test- prefix, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 8a55be19ba 06/42: Ignore empty Vorbis comments, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 9d71a515f7 09/42: Split emms-info-native to several files, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 29260a991a 11/42: Replace emms-info-native test files, ELPA Syncer, 2023/11/01
- [elpa] externals/emms fe9b0fffe1 16/42: Use strings instead of vectors for Vorbis comments, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 75f1ee292e 20/42: Add copyright information, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 5014dfa5f3 21/42: Ignore empty tags, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 16f107b583 24/42: Use bindat-type in emms-info-vorbis, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 6c3f1d6ab2 25/42: Use bindat-type in emms-info-opus,
ELPA Syncer <=
- [elpa] externals/emms 59e999a259 05/42: Fix error reporting from emms-info-native--ogg-page-bindat-spec, ELPA Syncer, 2023/11/01
- [elpa] externals/emms b512ed7331 03/42: Change magic arrays to patterns, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 5a52c1b129 22/42: Remove dependency on cl-lib, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 399dd78230 23/42: Use bindat-type in emms-info-ogg, ELPA Syncer, 2023/11/01
- [elpa] externals/emms e18b579e31 27/42: Use bindat-type in emms-info-mp3, ELPA Syncer, 2023/11/01
- [elpa] externals/emms f6bd021bc9 29/42: Compatibility code ert-resource-file, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 9db19a5abd 31/42: Remove emms--use-bindat-type, ELPA Syncer, 2023/11/01
- [elpa] externals/emms c848c18727 33/42: Change to emms-info-native- prefix, ELPA Syncer, 2023/11/01
- [elpa] externals/emms 342c44103a 35/42: Fix multi-channel mapping in Opus identification header, ELPA Syncer, 2023/11/01
- [elpa] externals/emms b3c2f9cf09 39/42: Use uintr for little-endian unsigned integer fields, ELPA Syncer, 2023/11/01