Line | Count | Source |
1 | | /* |
2 | | * FAAC - Freeware Advanced Audio Coder |
3 | | * Copyright (C) 2026 Nils Schimmelmann |
4 | | * |
5 | | * This library is free software; you can redistribute it and/or |
6 | | * modify it under the terms of the GNU Lesser General Public |
7 | | * License as published by the Free Software Foundation; either |
8 | | * version 2.1 of the License, or (at your option) any later version. |
9 | | * |
10 | | * This library is distributed in the hope that it will be useful, |
11 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | | * Lesser General Public License for more details. |
14 | | */ |
15 | | |
16 | | #ifndef FAAC_PS_H |
17 | | #define FAAC_PS_H |
18 | | |
19 | | #include <stdbool.h> |
20 | | #include <stdint.h> |
21 | | #include "faac_internal.h" |
22 | | |
23 | | #define PS_BANDS 20 |
24 | | #define PS_PHASE_BANDS 11 |
25 | | #define PS_LOW_BANDS 10 |
26 | | #define PS_LOW_PHASE_BANDS 5 |
27 | | #define PS_LOW_RATE_MAX_BITRATE 16000 /* total bits/s, explicit bitrate only */ |
28 | | |
29 | | struct SBRInfo; |
30 | | struct SBRContext; |
31 | | struct SignalAnalysis; |
32 | | struct SbrFrameData; |
33 | | struct BitStream; |
34 | | |
35 | | /* Preserve the preceding envelope for temporal deltas during rate-control retries. */ |
36 | | typedef struct PsRef { |
37 | | int8_t iid[PS_BANDS], icc[PS_BANDS], ipd[PS_PHASE_BANDS], opd[PS_PHASE_BANDS]; |
38 | | /* The header-carried state the decoder holds after this frame, plus the validity bit. */ |
39 | | uint8_t valid, band_mode, icc_on, ext_on; |
40 | | } PsRef; |
41 | | typedef struct PsHybrid { |
42 | | float history[2][3][6][2], coef[8][7][2]; |
43 | | int initialized; |
44 | | } PsHybrid; |
45 | | |
46 | | void PsHybridAnalyze(PsHybrid *, float[2][3][44][2], float[2][4][64], float[4][64], |
47 | | float[4][64], int); |
48 | | |
49 | | typedef struct PsCarrier { |
50 | | float history[2][256], overlap[256], window[512], invWindowPower[256]; |
51 | | float work[1024], leftSpectrum[1024]; |
52 | | int initialized; |
53 | | double smoothL, smoothR, smoothCross; |
54 | | } PsCarrier; |
55 | | |
56 | | void PsSpectralDownmix(PsCarrier *, float *, float *, float *, int); |
57 | | void PsDownmix(float *, const float *, int); |
58 | | |
59 | | /* Pass the preceding envelope for temporal deltas, or NULL when band modes differ. */ |
60 | | int PsWrite(const struct SbrFrameData *, struct BitStream *, const PsRef *); |
61 | | |
62 | | /* SBR integration hooks. Disabled builds inline these away and omit PS storage. |
63 | | * Carrier and extension hooks require the caller to check PsIsActive first. */ |
64 | | #if FAAC_ENCODER_PS |
65 | | void PsConfigure(struct SBRInfo *, bool, unsigned long, int); |
66 | | void PsPrepareCarrier(struct SBRContext *, float *[]); |
67 | | void PsCommitCarrier(struct SBRContext *, float *); |
68 | | void PsAnalyze(struct SBRInfo *, struct SignalAnalysis *, struct SbrFrameData *); |
69 | | void PsNoteSilence(struct SBRInfo *, struct SbrFrameData *); |
70 | | void PsWriteExtension(struct SBRInfo *, const struct SbrFrameData *, struct BitStream *); |
71 | | #else |
72 | | static inline void PsConfigure(struct SBRInfo *sbr, bool active, unsigned long bitrate, int rateLimited) |
73 | 0 | { |
74 | 0 | (void)sbr; (void)active; (void)bitrate; (void)rateLimited; |
75 | 0 | } Unexecuted instantiation: frame.c:PsConfigure Unexecuted instantiation: sbr.c:PsConfigure Unexecuted instantiation: sbr_analysis.c:PsConfigure Unexecuted instantiation: sbr_bitstream.c:PsConfigure |
76 | | static inline void PsPrepareCarrier(struct SBRContext *ctx, float *input[]) |
77 | 0 | { |
78 | 0 | (void)ctx; (void)input; |
79 | 0 | } Unexecuted instantiation: frame.c:PsPrepareCarrier Unexecuted instantiation: sbr.c:PsPrepareCarrier Unexecuted instantiation: sbr_analysis.c:PsPrepareCarrier Unexecuted instantiation: sbr_bitstream.c:PsPrepareCarrier |
80 | | static inline void PsCommitCarrier(struct SBRContext *ctx, float *output) |
81 | 0 | { |
82 | 0 | (void)ctx; (void)output; |
83 | 0 | } Unexecuted instantiation: frame.c:PsCommitCarrier Unexecuted instantiation: sbr.c:PsCommitCarrier Unexecuted instantiation: sbr_analysis.c:PsCommitCarrier Unexecuted instantiation: sbr_bitstream.c:PsCommitCarrier |
84 | | static inline void PsAnalyze(struct SBRInfo *sbr, struct SignalAnalysis *sa, struct SbrFrameData *fd) |
85 | 0 | { |
86 | 0 | (void)sbr; (void)sa; (void)fd; |
87 | 0 | } Unexecuted instantiation: frame.c:PsAnalyze Unexecuted instantiation: sbr.c:PsAnalyze Unexecuted instantiation: sbr_analysis.c:PsAnalyze Unexecuted instantiation: sbr_bitstream.c:PsAnalyze |
88 | | static inline void PsNoteSilence(struct SBRInfo *sbr, struct SbrFrameData *fd) |
89 | 0 | { |
90 | 0 | (void)sbr; (void)fd; |
91 | 0 | } Unexecuted instantiation: frame.c:PsNoteSilence Unexecuted instantiation: sbr.c:PsNoteSilence Unexecuted instantiation: sbr_analysis.c:PsNoteSilence Unexecuted instantiation: sbr_bitstream.c:PsNoteSilence |
92 | | static inline void PsWriteExtension(struct SBRInfo *sbr, const struct SbrFrameData *fd, struct BitStream *bs) |
93 | 0 | { |
94 | 0 | (void)sbr; (void)fd; (void)bs; |
95 | 0 | } Unexecuted instantiation: frame.c:PsWriteExtension Unexecuted instantiation: sbr.c:PsWriteExtension Unexecuted instantiation: sbr_analysis.c:PsWriteExtension Unexecuted instantiation: sbr_bitstream.c:PsWriteExtension |
96 | | #endif |
97 | | |
98 | | #if FAAC_ENCODER_PS && defined(FAAC_STATS) |
99 | | void PsCountFrame(const struct SBRInfo *, const struct SbrFrameData *, int); |
100 | | void PsStatsPrint(void); |
101 | | #else |
102 | | static inline void PsCountFrame(const struct SBRInfo *sbr, const struct SbrFrameData *fd, int id_aac) |
103 | 0 | { |
104 | 0 | (void)sbr; (void)fd; (void)id_aac; |
105 | 0 | } Unexecuted instantiation: frame.c:PsCountFrame Unexecuted instantiation: sbr.c:PsCountFrame Unexecuted instantiation: sbr_analysis.c:PsCountFrame Unexecuted instantiation: sbr_bitstream.c:PsCountFrame |
106 | 0 | static inline void PsStatsPrint(void) {}Unexecuted instantiation: frame.c:PsStatsPrint Unexecuted instantiation: sbr.c:PsStatsPrint Unexecuted instantiation: sbr_analysis.c:PsStatsPrint Unexecuted instantiation: sbr_bitstream.c:PsStatsPrint |
107 | | #endif |
108 | | |
109 | | #endif /* FAAC_PS_H */ |